aGrUM  0.14.2
DBTranslator4RangeVariable.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_RANGE_VARIABLE_H
26 #define GUM_LEARNING_DB_TRANSLATOR_4_RANGE_VARIABLE_H
27 
28 #include <agrum/agrum.h>
29 #include <agrum/core/hashTable.h>
30 #include <agrum/core/set.h>
33 
34 
35 namespace gum {
36 
37  namespace learning {
38 
39 
129  template < template < typename > class ALLOC = std::allocator >
130  class DBTranslator4RangeVariable : public DBTranslator< ALLOC > {
131  public:
134 
135 
136  // ##########################################################################
138  // ##########################################################################
139 
141 
143 
156  template < template < typename > class XALLOC >
158  const std::vector< std::string, XALLOC< std::string > >& missing_symbols,
159  std::size_t max_dico_entries = std::numeric_limits< std::size_t >::max(),
160  const allocator_type& alloc = allocator_type());
161 
163 
175  std::size_t max_dico_entries = std::numeric_limits< std::size_t >::max(),
176  const allocator_type& alloc = allocator_type());
177 
179 
198  template < template < typename > class XALLOC >
200  const RangeVariable& 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 
227  const RangeVariable& var,
228  const bool editable_dictionary = false,
229  std::size_t max_dico_entries = std::numeric_limits< std::size_t >::max(),
230  const allocator_type& alloc = allocator_type());
231 
234 
237  const allocator_type& alloc);
238 
241 
244  const allocator_type& alloc);
245 
248 
251  clone(const allocator_type& alloc) const;
252 
254  virtual ~DBTranslator4RangeVariable();
255 
257 
258 
259  // ##########################################################################
261  // ##########################################################################
262 
264 
268 
272 
274 
275 
276  // ##########################################################################
278  // ##########################################################################
279 
281 
283 
323  virtual DBTranslatedValue translate(const std::string& str) final;
324 
326 
329  virtual std::string
330  translateBack(const DBTranslatedValue translated_val) const final;
331 
333 
334  virtual std::size_t domainSize() const final;
335 
351  virtual bool needsReordering() const final;
352 
361  virtual HashTable< std::size_t,
362  std::size_t,
363  ALLOC< std::pair< std::size_t, std::size_t > > >
364  reorder() final;
365 
367  virtual const RangeVariable* variable() const final;
368 
370  virtual DBTranslatedValue missingValue() const final;
371 
373 
374 
375 #ifndef DOXYGEN_SHOULD_SKIP_THIS
376 
377  private:
378  // the RangeVariable assigned to the translator, if any
379  RangeVariable __variable;
380 
381  // assign to each integer missing symbol a Boolean indicating whether
382  // we already translated it or not. If we translated it, then we cannot
383  // change the range of the variable so that this range contains the symbol.
385  __status_int_missing_symbols;
386 
387  // the set of translations of the integer missing symbols found so far
388  Set< long, ALLOC< long > > __translated_int_missing_symbols;
389 
390  // a string containing a non int missing symbol
391  // (useful for back translations)
392  std::string __nonint_missing_symbol;
393 
394 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
395  };
396 
397 
398  } /* namespace learning */
399 
400 } /* namespace gum */
401 
402 
403 // always include the template implementation
405 
406 #endif /* GUM_LEARNING_DB_TRANSLATOR_4_RANGE_VARIABLE_H */
virtual bool needsReordering() const final
indicates whether a reordering is needed to make the translations sorted by increasing numbers ...
ALLOC< DBTranslatedValue > allocator_type
type for the allocators passed in arguments of methods
Definition: DBTranslator.h:117
virtual const RangeVariable * variable() const final
returns the variable stored into the translator
virtual std::string translateBack(const DBTranslatedValue translated_val) const final
returns the original value for a given translation
Sets of elements (i.e.
The databases&#39; cell translators for range variables.
STL namespace.
DBTranslator4RangeVariable< ALLOC > & operator=(const DBTranslator4RangeVariable< ALLOC > &from)
copy operator
The databases&#39; cell translators for range variables.
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 ~DBTranslator4RangeVariable()
destructor
virtual DBTranslatedValue missingValue() const final
returns the translation of a missing value
Representation of a setA Set is a structure that contains arbitrary elements.
Definition: set.h:162
The base class for all the tabular database cell translators.
Definition: DBTranslator.h:114
virtual DBTranslatedValue translate(const std::string &str) final
returns the translation of a string
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...
Defines a discrete random variable over an integer interval.
Definition: rangeVariable.h:51
virtual std::size_t domainSize() const final
returns the domain size of a variable corresponding to the translations
Header of gumRangeVariable.
typename DBTranslator< ALLOC >::allocator_type allocator_type
type for the allocators passed in arguments of methods
virtual DBTranslator4RangeVariable< ALLOC > * clone() const
virtual copy constructor
The base class for all the tabular databases&#39; cell translators.
Class hash tables iterators.
DBTranslator4RangeVariable(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