Outlet.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. /*!
  2. * \file Outlet.h
  3. * \author The VLE Development Team
  4. * See the AUTHORS or Authors.txt file
  5. * \version 2.0
  6. * \date 3 juin 2013
  7. */
  8. /*
  9. * Copyright (C) 2012-2013 ULCO http://www.univ-littoral.fr
  10. * Copyright (C) 2012-2013 INRA http://www.inra.fr
  11. *
  12. * This program is free software: you can redistribute it and/or modify
  13. * it under the terms of the GNU General Public License as published by
  14. * the Free Software Foundation, either version 3 of the License, or
  15. * (at your option) any later version.
  16. *
  17. * This program is distributed in the hope that it will be useful,
  18. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. * GNU General Public License for more details.
  21. *
  22. * You should have received a copy of the GNU General Public License
  23. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  24. */
  25. #ifndef OUTLET_H_
  26. #define OUTLET_H_
  27. #include "Node.h"
  28. #include <vector>
  29. #include <map>
  30. class Outlet : public Node
  31. {
  32. public :
  33. short getFlag() const {
  34. return _flag;
  35. }
  36. short getMx() const {
  37. return _mx;
  38. }
  39. short getGmx() const {
  40. return _Mx;
  41. }
  42. short getMy() const {
  43. return _my;
  44. }
  45. short getGmy() const {
  46. return _My;
  47. }
  48. int getNumber() const {
  49. return _number;
  50. }
  51. short getOrder() const {
  52. return _order;
  53. }
  54. void setFlag(short flag)
  55. {
  56. _flag = flag;
  57. }
  58. void setMx(short mx)
  59. {
  60. _mx = mx;
  61. }
  62. void setGMx(short mx)
  63. {
  64. _Mx = mx;
  65. }
  66. void setMy(short my)
  67. {
  68. _my = my;
  69. }
  70. void setGMy(short my)
  71. {
  72. _My = my;
  73. }
  74. void setNumber(int number)
  75. {
  76. _number = number;
  77. }
  78. void setOrder(short order)
  79. {
  80. _order = order;
  81. }
  82. Outlet() : Node()
  83. {
  84. _flag = 0;
  85. _order = 0;
  86. _mx = 0;
  87. _my = 0;
  88. _Mx = 0;
  89. _My = 0;
  90. _number = 0;
  91. }
  92. Outlet(const Outlet & o) : Node(o.getCoord(), o.getFather())
  93. {
  94. _father = o.getFather();
  95. _brother = o.getBrother();
  96. _child = o.getChild();
  97. _flag = o.getFlag();
  98. _number = o.getNumber() ;
  99. _order = o.getOrder();
  100. _mx = o.getMx();
  101. _my = o.getMy();
  102. _Mx = o.getGmx();
  103. _My = o.getGmy();
  104. }
  105. Outlet(const Coordinates & c, short flag, int outletsNumber) : Node(c, NULL)
  106. {
  107. _child = NULL;
  108. _brother = NULL;
  109. _flag = flag;
  110. _number = outletsNumber ;
  111. _order = 0;
  112. _mx = 0;
  113. _my = 0;
  114. _Mx = 0;
  115. _My = 0;
  116. }
  117. ~Outlet()
  118. {
  119. for(std::map<Coordinates, Node *>::iterator it = _childrenNodes.begin(); it!=_childrenNodes.end();it++)
  120. delete it->second;
  121. }
  122. void setNodes(const std::map<Coordinates, Node*>& nodes)
  123. {
  124. this->_childrenNodes = nodes;
  125. }
  126. const std::string toString() const
  127. {
  128. std::stringstream ss;
  129. ss<<"Outlet : "<<_coord.toString()<<"flag "<<_flag<<" numero "<<_number<<std::endl;
  130. ss <<"All nodes : \n";
  131. for(std::map<Coordinates, Node *>::const_iterator it = _childrenNodes.begin(); it!=_childrenNodes.end();it++)
  132. ss << it->second->toString()<<"\n:";
  133. return ss.str();
  134. }
  135. Node * searchChildNode(const Coordinates & coord) const
  136. {
  137. if(_childrenNodes.count(coord))
  138. return _childrenNodes.find(coord)->second;
  139. return NULL;
  140. }
  141. private :
  142. std::map<Coordinates, Node *>_childrenNodes;
  143. short _flag;
  144. short _order;
  145. short _mx, _my, _Mx, _My ;
  146. int _number ;
  147. };
  148. #endif /* OUTLET_H_ */