aGrUM  0.14.2
DBTranslator4LabelizedVariable.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2005 by Christophe GONZALES and Pierre-Henri WUILLEMIN *
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_LABELIZED_VARIABLE_H
26 #define GUM_LEARNING_DB_TRANSLATOR_4_LABELIZED_VARIABLE_H
27 
28 #include <agrum/agrum.h>
31 
32 
33 namespace gum {
34 
35  namespace learning {
36 
37 
131  template < template < typename > class ALLOC = std::allocator >
133  public:
136 
137  // ##########################################################################
139  // ##########################################################################
140 
142 
144 
157  template < template < typename > class XALLOC >
159  const std::vector< std::string, XALLOC< std::string > >& missing_symbols,
160  std::size_t max_dico_entries = std::numeric_limits< std::size_t >::max(),
161  const allocator_type& alloc = allocator_type());
162 
164 
176  std::size_t max_dico_entries = std::numeric_limits< std::size_t >::max(),
177  const allocator_type& alloc = allocator_type());
178 
180 
198  template < template < typename > class XALLOC >
200  const LabelizedVariable& var,
201  const std::vector< std::string, XALLOC< std::string > >& missing_symbols,
202  const bool editable_dictionary = false,
203  std::size_t max_dico_entries = std::numeric_limits< std::size_t >::max(),
204  const allocator_type& alloc = allocator_type());
205 
226  const LabelizedVariable& var,
227  const bool editable_dictionary = false,
228  std::size_t max_dico_entries = std::numeric_limits< std::size_t >::max(),
229  const allocator_type& alloc = allocator_type());
230 
234 
238  const allocator_type& alloc);
239 
243 
247  const allocator_type& alloc);
248 
251 
254  clone(const allocator_type& alloc) const;
255 
258 
260 
261 
262  // ##########################################################################
264  // ##########################################################################
265 
267 
271 
275 
277 
278 
279  // ##########################################################################
281  // ##########################################################################
282 
284 
286 
312  virtual DBTranslatedValue translate(const std::string& str) final;
313 
315 
321  virtual std::string
322  translateBack(const DBTranslatedValue translated_val) const final;
323 
325 
332  virtual std::size_t domainSize() const final;
333 
354  virtual bool needsReordering() const final;
355 
365  virtual HashTable< std::size_t,
366  std::size_t,
367  ALLOC< std::pair< std::size_t, std::size_t > > >
368  reorder() final;
369 
371  virtual const LabelizedVariable* variable() const final;
372 
374  virtual DBTranslatedValue missingValue() const final;
375 
377 
378 #ifndef DOXYGEN_SHOULD_SKIP_THIS
379 
380  private:
381  // the LabelizedVariable assigned to the translator, if any
382  LabelizedVariable __variable;
383 
384 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
385  };
386 
387 
388  } /* namespace learning */
389 
390 } /* namespace gum */
391 
392 
393 // always include the template implementation
395 
396 #endif /* GUM_LEARNING_DB_TRANSLATOR_4_LABELIZED_VARIABLE_H */
virtual const LabelizedVariable * variable() const final
returns the variable stored into the translator
virtual DBTranslatedValue missingValue() const final
returns the translation of a missing value
ALLOC< DBTranslatedValue > allocator_type
type for the allocators passed in arguments of methods
Definition: DBTranslator.h:117
virtual ~DBTranslator4LabelizedVariable()
destructor
The databases&#39; cell translators for labelized variables.
class LabelizedVariable
DBTranslator4LabelizedVariable(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 without any initial variable
virtual std::size_t domainSize() const final
returns the domain size of a variable corresponding to the translations
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
DBTranslator4LabelizedVariable< ALLOC > & operator=(const DBTranslator4LabelizedVariable< ALLOC > &from)
copy operator
The base class for all the tabular database cell translators.
Definition: DBTranslator.h:114
virtual bool needsReordering() const final
indicates whether a reordering is needed to make the translations sorted
virtual DBTranslatedValue translate(const std::string &str) final
returns the translation of a string
virtual DBTranslator4LabelizedVariable< ALLOC > * clone() const
virtual copy constructor
The base class for all the tabular databases&#39; cell translators.
The databases&#39; cell translators for labelized variables.
virtual HashTable< std::size_t, std::size_t, ALLOC< std::pair< std::size_t, std::size_t > > > reorder() final
performs a reordering of the dictionary and returns a mapping from the old translated values to the n...
typename DBTranslator< ALLOC >::allocator_type allocator_type
type for the allocators passed in arguments of methods
Base class for labelized discrete random variables.