Actual source code: Stack.hh

  1: #ifndef included_ALE_Stack_hh
  2: #define included_ALE_Stack_hh

  4: #ifndef  included_ALE_Sieve_hh
  5: #include <Sieve.hh>
  6: #endif

  8: namespace ALE {


 11:   class Stack : public PreSieve {
 12:   protected:
 13:     Obj<PreSieve>             _top;
 14:     Obj<PreSieve>             _bottom;
 15:   public:
 16:     Stack() : PreSieve(){};
 17:     Stack(MPI_Comm comm) : PreSieve(comm), _top((PreSieve*)NULL), _bottom((PreSieve *)NULL) {};
 18:     Stack(Obj<PreSieve> top,Obj<PreSieve> bottom): PreSieve(top->getComm()),_top(top),_bottom(bottom){
 19:       CHKCOMMS(*top.ptr(),*bottom.ptr());
 20:     };
 21:     Stack(PreSieve& top, PreSieve& bottom) : PreSieve(top.getComm()), _top(&top), _bottom(&bottom) {CHKCOMMS(top,bottom);};
 22:     virtual                   ~Stack(){};
 23:     virtual Stack&            clear() {PreSieve::clear(); this->_top = Obj<PreSieve>(); this->_bottom = Obj<PreSieve>(); return *this;};
 24:     //----------------------------------------------------------------------
 25:     // Virtual methods overloaded
 26:     virtual Stack&                    getLock(){
 27:       PreSieve::getLock();
 28:       if(!this->_top.isNull()) {
 29:         this->_top->getLock();
 30:       }
 31:       if(!this->_bottom.isNull()) {
 32:         this->_bottom->getLock();
 33:       }
 34:       return *this;
 35:     };
 36:     virtual Stack&                    releaseLock(){
 37:       PreSieve::releaseLock();
 38:       if(!this->_top.isNull()) {
 39:         this->_top->releaseLock();
 40:       }
 41:       if(!this->_bottom.isNull()) {
 42:         this->_bottom->releaseLock();
 43:       }
 44:       return *this;
 45:     };
 46:     Stack&                    stackAbove(Stack& s);
 47:     Stack&                    stackBelow(Stack& s);
 48:     Stack&                    invert();
 49:     Stack&                    addBasePoint(Point& p);
 50:     Stack&                    addCapPoint(Point& q);
 51:     // Point removal methods act only on the inherited (PreSieve) part of Stack, so they are inherited
 52:     // Inherited arrow manipulation methods (add/removeArrow, add/setCone/Support, etc)
 53:     // rely on addBasePoint/addCapPoint, so no need to redefine those.
 54:     Obj<Point_set>            space();
 55:     int32_t                   spaceSize(){return this->space()->size();};
 56:     int32_t                   baseSize(){return this->_bottom->spaceSize();};
 57:     Point_set                 base() {return this->_bottom->space();};
 58:     int32_t                   capSize(){return this->_top->spaceSize();};
 59:     Point_set                 cap()  {return this->_top->space();};
 60:     int                       spaceContains(Point p) {return (this->_top->spaceContains(p) || this->_bottom->spaceContains(p));};
 61:     int                       baseContains(Point p) {return this->_bottom->spaceContains(p);};
 62:     int                       capContains(Point p) {return this->_top->spaceContains(p);};
 63:     void                      view(const char *name);
 64:     //----------------------------------------------------------------------
 65:     // New and non-covariant methods
 66:     Obj<PreSieve>             top();
 67:     Obj<PreSieve>             left();
 68:     Stack&                    setTop(Obj<PreSieve> top);
 69:     Stack&                    setLeft(Obj<PreSieve> left);
 70:     Obj<PreSieve>             bottom();
 71:     Obj<PreSieve>             right();
 72:     Stack&                    setBottom(Obj<PreSieve> bottom);
 73:     Stack&                    setRight(Obj<PreSieve> right);
 74:     // Non-covariant methods redefined with the correct return type
 75:     virtual Stack*            baseRestriction(Point_set& base);
 76:     virtual Stack*            capRestriction(Point_set& cap);
 77:     // Exclusion methods act only on the inherited (PreSieve) part of Stack, so they could be inherited, but for the return type
 78:     virtual Stack*            baseExclusion(Point_set& base);
 79:     virtual Stack*            capExclusion(Point_set& cap);
 80:   };

 82: 
 83: } // namespace ALE

 85: #endif