aGrUM  0.14.2
DBTranslator4DiscretizedVariable.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2005 by Pierre-Henri WUILLEMIN et Christophe GONZALES *
3  * {prenom.nom}_at_lip6.fr *
4  * *
5  * This program is free software; you can redistribute it and/or modify *
6  * it under the terms of the GNU General Public License as published by *
7  * the Free Software Foundation; either version 2 of the License, or *
8  * (at your option) any later version. *
9  * *
10  * This program 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 *
13  * GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the GNU General Public License *
16  * along with this program; if not, write to the *
17  * Free Software Foundation, Inc., *
18  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19  ***************************************************************************/
25 #ifndef GUM_LEARNING_DB_TRANSLATOR_4_DISCRETIZED_VARIABLE_H
26 #define GUM_LEARNING_DB_TRANSLATOR_4_DISCRETIZED_VARIABLE_H
27 
28 #include <agrum/agrum.h>
31 
32 
33 namespace gum {
34 
35  namespace learning {
36 
37 
117  template < template < typename > class ALLOC = std::allocator >
119  public:
122 
123 
124  // ##########################################################################
126  // ##########################################################################
127 
129 
131 
144  template < typename GUM_SCALAR, template < typename > class XALLOC >
147  const std::vector< std::string, XALLOC< std::string > >& missing_symbols,
148  std::size_t max_dico_entries = std::numeric_limits< std::size_t >::max(),
149  const allocator_type& alloc = allocator_type());
150 
165  template < typename GUM_SCALAR >
168  std::size_t max_dico_entries = std::numeric_limits< std::size_t >::max(),
169  const allocator_type& alloc = allocator_type());
170 
172 
185  template < template < typename > class XALLOC >
187  const IDiscretizedVariable& var,
188  const std::vector< std::string, XALLOC< std::string > >& missing_symbols,
189  std::size_t max_dico_entries = std::numeric_limits< std::size_t >::max(),
190  const allocator_type& alloc = allocator_type());
191 
207  const IDiscretizedVariable& var,
208  std::size_t max_dico_entries = std::numeric_limits< std::size_t >::max(),
209  const allocator_type& alloc = allocator_type());
210 
214 
218  const allocator_type& alloc);
219 
223 
227  const allocator_type& alloc);
228 
231 
234  clone(const allocator_type& alloc) const;
235 
238 
240 
241 
242  // ##########################################################################
244  // ##########################################################################
245 
247 
251 
255 
257 
258 
259  // ##########################################################################
261  // ##########################################################################
262 
264 
266 
284  virtual DBTranslatedValue translate(const std::string& str) final;
285 
287 
290  virtual std::string
291  translateBack(const DBTranslatedValue translated_val) const final;
292 
294 
297  virtual std::size_t domainSize() const final;
298 
300  virtual bool hasEditableDictionary() const final;
301 
303  virtual void setEditableDictionaryMode(bool new_mode) final;
304 
306  virtual bool needsReordering() const final;
307 
310  virtual HashTable< std::size_t,
311  std::size_t,
312  ALLOC< std::pair< std::size_t, std::size_t > > >
313  reorder() final;
314 
316  virtual const IDiscretizedVariable* variable() const final;
317 
319  virtual DBTranslatedValue missingValue() const final;
320 
322 
323 
324 #ifndef DOXYGEN_SHOULD_SKIP_THIS
325 
326  private:
327  // the DiscretizedVariable used for translations
328  DiscretizedVariable< float > __variable;
329 
330  // the DiscretizedVariable returned by method variable ()
331  // We must return a IDiscretizedVariable because the user may have
332  // saved into the translator a DiscretizedVariable<X>, with X != float
333  IDiscretizedVariable* __real_variable;
334 
335 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
336  };
337 
338 
339  } /* namespace learning */
340 
341 } /* namespace gum */
342 
343 
344 // always include the template implementation
346 
347 #endif /* GUM_LEARNING_DB_TRANSLATOR_4_DISCRETIZED_VARIABLE_H */
DBTranslator4DiscretizedVariable< ALLOC > & operator=(const DBTranslator4DiscretizedVariable< ALLOC > &from)
copy operator
ALLOC< DBTranslatedValue > allocator_type
type for the allocators passed in arguments of methods
Definition: DBTranslator.h:117
virtual DBTranslator4DiscretizedVariable< ALLOC > * clone() const
virtual copy constructor
virtual DBTranslatedValue translate(const std::string &str) final
returns the translation of a string
Class for discretized random variable.
STL namespace.
virtual std::string translateBack(const DBTranslatedValue translated_val) const final
returns the original value for a given translation
gum is the global namespace for all aGrUM entities
Definition: agrum.h:25
The union class for storing the translated values in learning databases.
The class for generic Hash Tables.
Definition: hashTable.h:676
virtual const IDiscretizedVariable * variable() const final
returns the variable stored into the translator
virtual DBTranslatedValue missingValue() const final
returns the translation of a missing value
virtual bool hasEditableDictionary() const final
indicates that the translator is never in editable dictionary mode
virtual bool needsReordering() const final
indicates that the translations should never be reordered
The databases&#39; cell translators for discretized variables.
The base class for all the tabular database cell translators.
Definition: DBTranslator.h:114
DBTranslator4DiscretizedVariable(const DiscretizedVariable< GUM_SCALAR > &var, const std::vector< std::string, XALLOC< std::string > > &missing_symbols, std::size_t max_dico_entries=std::numeric_limits< std::size_t >::max(), const allocator_type &alloc=allocator_type())
default constructor with a discretized variable as translator
The databases&#39; cell translators for discretized variables.
virtual std::size_t domainSize() const final
returns the number of discretization intervals used for translations
virtual HashTable< std::size_t, std::size_t, ALLOC< std::pair< std::size_t, std::size_t > > > reorder() final
returns an empty HashTable to indicate that no reordering is needed.
typename DBTranslator< ALLOC >::allocator_type allocator_type
type for the allocators passed in arguments of methods
The base class for all the tabular databases&#39; cell translators.
virtual void setEditableDictionaryMode(bool new_mode) final
sets/unset the editable dictionary mode
A base class for discretized variables, independent of the ticks type.