$extrastylesheet
Olena  User documentation 2.1
An Image Processing Platform
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
component.hh
1 // Copyright (C) 2009, 2010, 2011, 2013 EPITA Research and Development
2 // Laboratory (LRDE)
3 //
4 // This file is part of Olena.
5 //
6 // Olena is free software: you can redistribute it and/or modify it under
7 // the terms of the GNU General Public License as published by the Free
8 // Software Foundation, version 2 of the License.
9 //
10 // Olena is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 // General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with Olena. If not, see <http://www.gnu.org/licenses/>.
17 //
18 // As a special exception, you may use this file as part of a free
19 // software project without restriction. Specifically, if other files
20 // instantiate templates or use macros or inline functions from this
21 // file, or you compile this file and link it with other files to produce
22 // an executable, this file does not by itself cause the resulting
23 // executable to be covered by the GNU General Public License. This
24 // exception does not however invalidate any other reasons why the
25 // executable file might be covered by the GNU General Public License.
26 
27 #ifndef SCRIBO_CORE_TAG_COMPONENT_HH
28 # define SCRIBO_CORE_TAG_COMPONENT_HH
29 
33 
34 # include <iostream>
35 
36 namespace scribo
37 {
38 
40  struct ComponentId;
41 
42 
43  namespace component
44  {
45 
54  enum Tag
55  {
56  None = 0,
58  };
59 
60 
69  enum Type
70  {
71  Undefined = 0,
80  };
81 
82 
85  std::ostream& operator<<(std::ostream& ostr, const Tag& tag);
86 
88  Tag str2tag(const std::string& str);
89 
92  std::ostream& operator<<(std::ostream& ostr, const Type& type);
94  Type str2type(const std::string& str);
95 
96 
97 # ifndef MLN_INCLUDE_ONLY
98 
99 
100  inline
101  std::ostream&
102  operator<<(std::ostream& ostr, const Tag& tag)
103  {
104  std::string str;
105  switch(tag)
106  {
107  default:
108  case None:
109  str = "None";
110  break;
111  case Ignored:
112  str = "Ignored";
113  break;
114  }
115 
116  return ostr << str;
117  }
118 
119 
120  inline
121  Tag str2tag(const std::string& str)
122  {
123  if (str == "Ignored")
124  return Ignored;
125 
126  return None;
127  }
128 
129 
130  inline
131  std::ostream&
132  operator<<(std::ostream& ostr, const Type& type)
133  {
134  std::string str;
135  switch(type)
136  {
137  default:
138  case Undefined:
139  str = "Undefined";
140  break;
141  case Character:
142  str = "Character";
143  break;
145  str = "HorizontalLineSeparator";
146  break;
148  str = "VerticalLineSeparator";
149  break;
150  case WhitespaceSeparator:
151  str = "WhitespaceSeparator";
152  break;
153  case Noise:
154  str = "Noise";
155  break;
156  case Punctuation:
157  str = "Punctuation";
158  break;
159  case Image:
160  str = "Image";
161  case DropCapital:
162  str = "DropCapital";
163  break;
164  }
165 
166  return ostr << str;
167  }
168 
169 
170  inline
171  Type str2type(const std::string& str)
172  {
173  if (str == "Character")
174  return Character;
175  else if (str == "HorizontalLineSeparator")
177  else if (str == "VerticalLineSeparator")
178  return VerticalLineSeparator;
179  else if (str == "WhitespaceSeparator")
180  return WhitespaceSeparator;
181  else if (str == "Noise")
182  return Noise;
183  else if (str == "Punctuation")
184  return Punctuation;
185  else if (str == "Image")
186  return Image;
187  else if (str == "DropCapital")
188  return DropCapital;
189 
190  return Undefined;
191  }
192 
193 # endif // ! MLN_INCLUDE_ONLY
194 
195 
196  } // end of namespace scribo::component
197 
198 } // end of namespace scribo
199 
200 
201 #endif // ! SCRIBO_CORE_TAG_COMPONENT_HH