aGrUM  0.14.2
rawDatabaseTable.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  ***************************************************************************/
39 #ifndef GUM_RAW_DATABASE_TABLE_H
40 #define GUM_RAW_DATABASE_TABLE_H
41 
42 
43 #include <agrum/agrum.h>
46 
47 namespace gum {
48 
49  namespace learning {
50 
112  template < template < typename > class ALLOC = std::allocator >
113  class RawDatabaseTable : public IDatabaseTable< DBCell, ALLOC > {
114  public:
116  template < typename TX_DATA >
117  using DBVector = std::vector< TX_DATA, ALLOC< TX_DATA > >;
118 
120  template < typename TX_DATA >
122 
124  template < typename TX_DATA >
126 
127  template < template < typename > class XALLOC >
128  using MissingValType = std::vector< std::string, XALLOC< std::string > >;
129 
132 
135 
137 
142  using const_reference = const value_type&;
143  using pointer = value_type*;
144  using const_pointer = const value_type*;
145  using size_type = std::size_t;
146  using difference_type = std::ptrdiff_t;
147  using iterator = Handler;
149  using allocator_type = ALLOC< DBCell >;
151 
152 
153  // ##########################################################################
155  // ##########################################################################
157 
159  template < template < typename > class VARALLOC,
160  template < typename >
161  class MISSALLOC >
163  const MissingValType< MISSALLOC >& missing_symbols,
164  const std::vector< std::string, VARALLOC< std::string > >& var_names,
165  const allocator_type& alloc = allocator_type());
166 
168  template < template < typename > class MISSALLOC >
169  RawDatabaseTable(const MissingValType< MISSALLOC >& missing_symbols,
170  const allocator_type& alloc = allocator_type());
171 
174 
177 
180  const allocator_type& alloc);
181 
184 
187  const allocator_type& alloc);
188 
190  virtual RawDatabaseTable< ALLOC >* clone() const final;
191 
193  virtual RawDatabaseTable< ALLOC >*
194  clone(const allocator_type& alloc) const final;
195 
197  virtual ~RawDatabaseTable();
198 
200 
201 
202  // ##########################################################################
204  // ##########################################################################
206 
208  RawDatabaseTable< ALLOC >& operator=(const RawDatabaseTable< ALLOC >& from);
209 
211  RawDatabaseTable< ALLOC >& operator=(RawDatabaseTable< ALLOC >&& from);
212 
214 
215 
216  // ##########################################################################
218  // ##########################################################################
220 
221  using IDatabaseTable< DBCell, ALLOC >::setVariableNames;
222 
224 
249  virtual void setVariableNames(
250  const std::vector< std::string, ALLOC< std::string > >& names,
251  const bool from_external_object = true) final;
252 
254 
283  virtual void ignoreColumn(const std::size_t k,
284  const bool from_external_object = true) final;
285 
287  virtual const DBVector< std::size_t > ignoredColumns() const final;
288 
291  virtual const DBVector< std::size_t > inputColumns() const final;
292 
293  using IDatabaseTable< DBCell, ALLOC >::insertRow;
294 
296 
302  virtual void insertRow(
303  const std::vector< std::string, ALLOC< std::string > >& new_row) final;
304 
306  virtual void clear() final;
307 
309 
310 
311 #ifndef DOXYGEN_SHOULD_SKIP_THIS
312 
313  private:
314  // the set of ignored columns, sorted by increasing order
315  DBVector< std::size_t > __ignored_cols;
316 
318  DBCell __convert(const std::string& elt) const;
319 
320 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
321  };
322 
323  } /* namespace learning */
324 
325 } /* namespace gum */
326 
329 
330 #endif /* GUM_RAW_DATABASE_TABLE_H */
typename IDatabaseTable< DBCell, ALLOC >::IsMissing IsMissing
The common class for the tabular database tables.
The table containing the raw/original data of a databaseClass RawDatabaseTable is intended to store i...
The implementation of raw tabular databases stored in memory (RAM)
virtual void ignoreColumn(const std::size_t k, const bool from_external_object=true) final
makes the database table ignore from now on the kth column
The class representing the original values of the cells of databases.
Definition: DBCell.h:69
STL namespace.
virtual const DBVector< std::size_t > ignoredColumns() const final
returns the set of columns of the original dataset that are ignored
HandlerSafe iterator_safe
Types for STL compliance.
virtual const DBVector< std::size_t > inputColumns() const final
returns the set of columns of the original dataset that are present in the RawDatabaseTable ...
gum is the global namespace for all aGrUM entities
Definition: agrum.h:25
std::ptrdiff_t difference_type
Types for STL compliance.
ALLOC< DBCell > allocator_type
Types for STL compliance.
The class representing the original values of the cells of databases.
The class for storing a record in a database.
Definition: DBRow.h:53
typename IDatabaseTable< DBCell, ALLOC >::HandlerSafe HandlerSafe
the safe handler type
std::vector< TX_DATA, ALLOC< TX_DATA > > DBVector
the type for the vectors used in the RawDatabaseTable
virtual void insertRow(const std::vector< std::string, ALLOC< std::string > > &new_row) final
insert a new row at the end of the database
RawDatabaseTable(const MissingValType< MISSALLOC > &missing_symbols, const std::vector< std::string, VARALLOC< std::string > > &var_names, const allocator_type &alloc=allocator_type())
default constructor
typename IDatabaseTable< DBCell, ALLOC >::Handler Handler
the unsafe handler type
std::size_t size_type
Types for STL compliance.
std::vector< std::string, XALLOC< std::string > > MissingValType
virtual RawDatabaseTable< ALLOC > * clone() const final
virtual copy constructor
virtual void clear() final
erase the content of the database, including the names of the variables
DBVector< Row< TX_DATA > > Matrix
the type for the matrices stored into the database
The common class for the tabular database tables.
virtual void setVariableNames(const std::vector< std::string, ALLOC< std::string > > &names, const bool from_external_object=true) final
sets the names of the variables
Handler iterator
Types for STL compliance.