$extrastylesheet
Olena  User documentation 2.1
An Image Processing Platform
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
window/print.hh
1 // Copyright (C) 2008, 2009 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 
26 #ifndef MLN_TRAIT_WINDOW_PRINT_HH
27 # define MLN_TRAIT_WINDOW_PRINT_HH
28 
34 # include <iostream>
35 
36 # include <mln/trait/windows.hh>
37 # include <mln/metal/is_a.hh>
38 # include <mln/metal/bexpr.hh>
39 
40 
41 
42 namespace mln
43 {
44 
45  // Forward declaration.
46  template <typename E> struct Window;
47  template <typename E> struct Weighted_Window;
48  template <typename E> struct Neighborhood;
49 
50 
51  namespace trait
52  {
53 
54  namespace window
55  {
56 
57  template <typename T>
58  void print(std::ostream& ostr = std::cout);
59 
60  template <typename T>
61  void print(const Neighborhood<T>& nbh, std::ostream& ostr = std::cout);
62 
63  template <typename T>
64  void print(const Window<T>& win, std::ostream& ostr = std::cout);
65 
66  template <typename T>
67  void print(const Weighted_Window<T>& w_win, std::ostream& ostr = std::cout);
68 
69 
70 # ifndef MLN_INCLUDE_ONLY
71 
72  template <typename T>
73  inline
74  void print(std::ostream& ostr)
75  {
76  metal::or_< mlc_is_a(T, Neighborhood),
77  metal::or_< mlc_is_a(T, Window),
78  mlc_is_a(T, Weighted_Window) >
79  >::check();
80  typedef mln::trait::window_<T> the;
81  ostr << "{ "
82  << typename the::size() .name() << ", "
83  << typename the::support() .name() << ", "
84  << typename the::definition() .name() << " }" << std::endl;
85  }
86 
87  template <typename T>
88  inline
89  void print(const Neighborhood<T>&, std::ostream& ostr)
90  {
91  print<T>(ostr);
92  }
93 
94  template <typename T>
95  inline
96  void print(const Window<T>&, std::ostream& ostr)
97  {
98  print<T>(ostr);
99  }
100 
101  template <typename T>
102  inline
103  void print(const Weighted_Window<T>&, std::ostream& ostr)
104  {
105  print<T>(ostr);
106  }
107 
108 # endif // ! MLN_INCLUDE_ONLY
109 
110  } // end of namespace mln::trait::window
111 
112  } // end of namespace mln::trait
113 
114 } // end of namespace mln
115 
116 
117 #endif // ! MLN_TRAIT_WINDOW_PRINT_HH