Changeset 519eaf5 for src/dgp/boubble.hh


Ignore:
Timestamp:
03/30/14 23:59:06 (10 years ago)
Author:
Tomasz Obrebski <obrebski@…>
Branches:
master
Children:
0a58b3f
Parents:
f924e4b
git-author:
Tomasz Obrebski <obrebski@…> (03/30/14 23:59:06)
git-committer:
Tomasz Obrebski <obrebski@…> (03/30/14 23:59:06)
Message:

Bug fixes: bubbles,props

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/dgp/boubble.hh

    r3b02b04 r519eaf5  
    2424{ 
    2525public: 
    26   Boubble(list<Role> u, list<Role> d, LongRel l, int s=-1); 
    27   Boubble(const char* pathstr, const char* l, int s=-1); 
    28   //  Boubble(const Boubble& b) {_src=b._src; _upath=b._upath; _dpath=b._dpath; _rel=b._rel; }; 
    29  
    30   Dir dir(); 
    31   LongRel rel(); 
    32   int src(); 
     26  Boubble() {}; 
     27  Boubble(list<Role> u, list<Role> d, LongRel l, int s=-1, bool r=false); 
     28  Boubble(const char* pathstr, const char* l, int s=-1, bool r=false); 
     29  //Boubble(const Boubble& b) {_src=b._src; _upath=b._upath; _dpath=b._dpath; _rel=b._rel; _reverse=b._reverse; }; 
     30 
     31  Dir dir() const; 
     32  LongRel rel() const; 
     33  int src() const; 
    3334  void src(int s); 
     35  bool reverse() const; 
     36  void reverse(bool b); 
    3437 
    3538  Role next(); 
    3639 
    3740  Boubble* step(Role r, Dir d); 
    38    
    39   bool is_at_target(); 
     41  Boubble* reversed(); 
     42   
     43  bool is_at_target() const; 
    4044 
    4145  bool operator==(Boubble const& b) const; 
     
    5256  list<Role>           _dpath; 
    5357  LongRel              _rel; 
     58  bool                 _reverse; 
    5459 
    5560}; 
     
    5863 
    5964inline 
    60 Boubble::Boubble(list<Role> u, list<Role> d, LongRel l, int s) : _upath(u), _dpath(d), _rel(l), _src(s) {} 
    61  
    62 //---------------------------------------------------------------------------------------------------- 
    63  
    64 inline 
    65 Boubble::Boubble(const char* pathstr, const char* l, int s) 
     65Boubble::Boubble(list<Role> u, list<Role> d, LongRel l, int s, bool r) 
     66  : _upath(u), _dpath(d), _rel(l), _src(s), _reverse(r) {} 
     67 
     68//---------------------------------------------------------------------------------------------------- 
     69 
     70inline 
     71Boubble::Boubble(const char* pathstr, const char* l, int s, bool r) 
    6672{ 
    6773  Dir dir = UP; 
     
    8389  _rel = LongRel(l); 
    8490  _src = s; 
    85 } 
    86  
    87 //---------------------------------------------------------------------------------------------------- 
    88  
    89 inline 
    90 Dir Boubble::dir() 
     91  _reverse = r; 
     92} 
     93 
     94//---------------------------------------------------------------------------------------------------- 
     95 
     96inline 
     97Dir Boubble::dir() const 
    9198{  
    9299  if(!_upath.empty()) 
     
    100107 
    101108inline 
    102 LongRel Boubble::rel() 
     109LongRel Boubble::rel() const 
    103110{ return _rel; } 
    104111 
     
    106113 
    107114inline 
    108 int Boubble::src() 
     115int Boubble::src() const 
    109116{ return _src; } 
    110117 
     
    114121void Boubble::src(int s) 
    115122{ _src=s; } 
     123 
     124//---------------------------------------------------------------------------------------------------- 
     125 
     126inline 
     127bool Boubble::reverse() const 
     128{ return _reverse; } 
     129 
     130//---------------------------------------------------------------------------------------------------- 
     131 
     132inline 
     133void Boubble::reverse(bool b) 
     134{ _reverse=b; } 
    116135 
    117136//---------------------------------------------------------------------------------------------------- 
     
    134153  if(d==UP && !_upath.empty() && _upath.front() == r) 
    135154    { 
    136       Boubble* newboubble = new Boubble(_upath,_dpath,_rel,_src); 
     155      Boubble* newboubble = new Boubble(_upath,_dpath,_rel,_src,_reverse); 
    137156      newboubble->_upath.pop_front(); 
    138157      return newboubble; 
     
    141160  if(d==DOWN && _upath.empty() && !_dpath.empty() && _dpath.front() == r) 
    142161    { 
    143       Boubble* newboubble = new Boubble(_upath,_dpath,_rel,_src); 
     162      Boubble* newboubble = new Boubble(_upath,_dpath,_rel,_src,_reverse); 
    144163      newboubble->_dpath.pop_front(); 
    145164      return newboubble; 
     
    151170 
    152171inline 
    153 bool Boubble::is_at_target() 
     172Boubble* Boubble::reversed() 
     173{ 
     174  Boubble* newboubble = new Boubble(_dpath,_upath,_rel,-1,!_reverse); 
     175  newboubble->_upath.reverse(); 
     176  newboubble->_dpath.reverse(); 
     177  // cout << *this << "-----" << *newboubble << endl; 
     178  return newboubble; 
     179} 
     180 
     181//---------------------------------------------------------------------------------------------------- 
     182 
     183inline 
     184bool Boubble::is_at_target() const 
    154185{ return _upath.empty() && _dpath.empty(); } 
    155186 
     
    208239  o << b._rel.str(); 
    209240  o << "]"; 
     241  if(b.reverse()) o << "!"; 
     242  return o; 
    210243} 
    211244 
Note: See TracChangeset for help on using the changeset viewer.