$extrastylesheet
Olena  User documentation 2.1
An Image Processing Platform
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
node.hh
1 // Copyright (C) 2013 EPITA Research and Development Laboratory (LRDE)
2 //
3 // This file is part of Olena.
4 //
5 // Olena is free software: you can redistribute it and/or modify it under
6 // the terms of the GNU General Public License as published by the Free
7 // Software Foundation, version 2 of the License.
8 //
9 // Olena is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with Olena. If not, see <http://www.gnu.org/licenses/>.
16 //
17 // As a special exception, you may use this file as part of a free
18 // software project without restriction. Specifically, if other files
19 // instantiate templates or use macros or inline functions from this
20 // file, or you compile this file and link it with other files to produce
21 // an executable, this file does not by itself cause the resulting
22 // executable to be covered by the GNU General Public License. This
23 // exception does not however invalidate any other reasons why the
24 // executable file might be covered by the GNU General Public License.
25 
29 
30 
31 #ifndef SCRIBO_LAYOUT_INTERNAL_NODE_HH
32 # define SCRIBO_LAYOUT_INTERNAL_NODE_HH
33 
34 # include <mln/core/alias/box2d.hh>
35 
36 namespace scribo
37 {
38 
39  namespace layout
40  {
41 
42  namespace internal
43  {
44 
46  template <typename B>
47  class node
48  {
49  public:
50  node();
51  node(const B& bbox);
52 
53  ~node();
54 
55  const B& get_bbox() const;
56 
57  node<B>* get_ls();
58  const node<B>* get_ls() const;
59  node<B>* get_rs();
60  const node<B>* get_rs() const;
61 
62  bool is_leaf() const;
63 
64  void set_ls(node<B>* n);
65  void set_rs(node<B>* n);
66 
67  private:
68  B bbox_;
69  node<B>* ls_;
70  node<B>* rs_;
71  };
72 
73 # ifndef MLN_INCLUDE_ONLY
74 
75  template <typename B>
77  : ls_(0),
78  rs_(0)
79  {
80  }
81 
82  template <typename B>
83  node<B>::node(const B& bbox)
84  : bbox_(bbox),
85  ls_(0),
86  rs_(0)
87  {
88  }
89 
90  template <typename B>
91  node<B>::~node()
92  {
93  if (ls_)
94  delete ls_;
95 
96  if (rs_)
97  delete rs_;
98  }
99 
100  template <typename B>
101  const B& node<B>::get_bbox() const
102  {
103  return bbox_;
104  }
105 
106  template <typename B>
107  node<B>* node<B>::get_ls()
108  {
109  return ls_;
110  }
111 
112  template <typename B>
113  const node<B>* node<B>::get_ls() const
114  {
115  return ls_;
116  }
117 
118  template <typename B>
119  node<B>* node<B>::get_rs()
120  {
121  return rs_;
122  }
123 
124  template <typename B>
125  const node<B>* node<B>::get_rs() const
126  {
127  return rs_;
128  }
129 
130  template <typename B>
131  bool node<B>::is_leaf() const
132  {
133  return ls_ == rs_;
134  }
135 
136  template <typename B>
137  void node<B>::set_ls(node<B>* n)
138  {
139  ls_ = n;
140  }
141 
142  template <typename B>
143  void node<B>::set_rs(node<B>* n)
144  {
145  rs_ = n;
146  }
147 
148 # endif // ! MLN_INCLUDE_ONLY
149 
150  } // end of namespace scribo::layout::internal
151 
152  } // end of namespace scribo::layout
153 
154 } // end of namespace scribo
155 
156 #endif // ! SCRIBO_LAYOUT_INTERNAL_NODE_HH