STK++ 0.9.13
STK::CsvToArray< Array, Type > Class Template Reference

The CsvToArray class allow to export the data of some Type stored in a TReadWriteCsv in an Array. More...

#include <STK_CsvToArray.h>

Inheritance diagram for STK::CsvToArray< Array, Type >:
Inheritance graph

Public Types

typedef TReadWriteCsv< Type > Rw
 

Public Member Functions

 CsvToArray (Rw const &rw, Real const &propMiss=0.)
 Constructor.
 
 CsvToArray (CsvToArray const &exporter)
 copy constructor.
 
virtual ~CsvToArray ()
 destructor
 
CsvToArrayclone () const
 clone pattern
 
Real constpropMiss () const
 
void setPropMiss (Real const &propMiss)
 Set the maximal proportion of missing value allowed.
 
bool run ()
 run the export.
 
Array * p_data ()
 Accessor.
 
void release ()
 release the Array.
 
- Public Member Functions inherited from STK::IRunnerBase
String consterror () const
 get the last error message.
 

Private Attributes

Rw constrw_
 A reference to the TReadWriteCsv we want to export.
 
Array * p_data_
 A pointer on the 2D Container the class will create.
 
Real propMiss_
 proportion of missing values allowed
 

Additional Inherited Members

- Protected Member Functions inherited from STK::IRunnerBase
 IRunnerBase ()
 default constructor
 
 IRunnerBase (IRunnerBase const &runner)
 copy constructor
 
virtual ~IRunnerBase ()
 destructor
 
virtual void update ()
 update the runner.
 
- Protected Attributes inherited from STK::IRunnerBase
String msg_error_
 String with the last error message.
 
bool hasRun_
 true if run has been used, false otherwise
 

Detailed Description

template<class Array, class Type = typename Array::Type>
class STK::CsvToArray< Array, Type >

The CsvToArray class allow to export the data of some Type stored in a TReadWriteCsv in an Array.

The Variables are moved, so take care that the variables present in the TReadWriteCsv cannot be modified without affecting the Array.

The Array container is created on the stack and will be deleted with the CsvToArray structure. It is possible to release the Array container by calling explicitly the release() method. In this case the end user will have to free it directly.

It is possible to control the behavior of the import by specifying the maximal proportion of missing value (0 by default). Each column having more missing value will be discarded.

Definition at line 134 of file STK_CsvToArray.h.

Member Typedef Documentation

◆ Rw

template<class Array , class Type = typename Array::Type>
typedef TReadWriteCsv<Type> STK::CsvToArray< Array, Type >::Rw

Definition at line 137 of file STK_CsvToArray.h.

Constructor & Destructor Documentation

◆ CsvToArray() [1/2]

template<class Array , class Type = typename Array::Type>
STK::CsvToArray< Array, Type >::CsvToArray ( Rw const rw,
Real const propMiss = 0. 
)
inline

Constructor.

Parameters
rwthe TReadWriteCsv to import
propMissproportion of missing value allowed

Definition at line 142 of file STK_CsvToArray.h.

143 : rw_(rw), p_data_(0), propMiss_(propMiss)
144 {}
Rw const & rw_
A reference to the TReadWriteCsv we want to export.
Real propMiss_
proportion of missing values allowed
Array * p_data_
A pointer on the 2D Container the class will create.
Real const & propMiss() const

◆ CsvToArray() [2/2]

template<class Array , class Type = typename Array::Type>
STK::CsvToArray< Array, Type >::CsvToArray ( CsvToArray< Array, Type > const exporter)
inline

copy constructor.

Parameters
exporterthe CsvToArray to copy

Definition at line 148 of file STK_CsvToArray.h.

149 : rw_(exporter.rw_), p_data_(exporter.p_data_), propMiss_(exporter.propMiss_)
150 {}

◆ ~CsvToArray()

template<class Array , class Type = typename Array::Type>
virtual STK::CsvToArray< Array, Type >::~CsvToArray ( )
inlinevirtual

destructor

Definition at line 152 of file STK_CsvToArray.h.

152{ if (p_data_) delete p_data_;}

References STK::CsvToArray< Array, Type >::p_data_.

Member Function Documentation

◆ clone()

template<class Array , class Type = typename Array::Type>
CsvToArray * STK::CsvToArray< Array, Type >::clone ( ) const
inline

clone pattern

Definition at line 154 of file STK_CsvToArray.h.

154{ return new CsvToArray(*this);}
CsvToArray(Rw const &rw, Real const &propMiss=0.)
Constructor.

◆ p_data()

template<class Array , class Type = typename Array::Type>
Array * STK::CsvToArray< Array, Type >::p_data ( )
inline

Accessor.

get the Array. This method is not constant in order to allow to the user to modify directly the 2D container.

Returns
a ptr on the 2D container constructed

Definition at line 178 of file STK_CsvToArray.h.

178{ return p_data_;}

References STK::CsvToArray< Array, Type >::p_data_.

◆ propMiss()

template<class Array , class Type = typename Array::Type>
Real const & STK::CsvToArray< Array, Type >::propMiss ( ) const
inline
Returns
the maximal proportion of missing value allowed in each column

Definition at line 156 of file STK_CsvToArray.h.

156{ return propMiss_;}

References STK::CsvToArray< Array, Type >::propMiss_.

Referenced by STK::CsvToArray< Array, Type >::setPropMiss().

◆ release()

template<class Array , class Type = typename Array::Type>
void STK::CsvToArray< Array, Type >::release ( )
inline

release the Array.

It will be freed by the user.

Definition at line 180 of file STK_CsvToArray.h.

180{ p_data_ =0;}

References STK::CsvToArray< Array, Type >::p_data_.

◆ run()

template<class Array , class Type = typename Array::Type>
bool STK::CsvToArray< Array, Type >::run ( )
inlinevirtual

run the export.

Implements STK::IRunnerBase.

Definition at line 162 of file STK_CsvToArray.h.

163 {
164 try
165 {
166 p_data_ = new Array;
167 hidden::CsvToArrayImpl<Type, Array>::run(rw_, p_data_, propMiss_);
168 return true;
169 }
170 catch (Exception const& e)
171 { msg_error_ = e.error();}
172 return false;
173 }
String msg_error_
String with the last error message.
Definition STK_IRunner.h:96

References STK::IRunnerBase::error(), STK::IRunnerBase::msg_error_, STK::CsvToArray< Array, Type >::p_data_, STK::CsvToArray< Array, Type >::propMiss_, and STK::CsvToArray< Array, Type >::rw_.

◆ setPropMiss()

template<class Array , class Type = typename Array::Type>
void STK::CsvToArray< Array, Type >::setPropMiss ( Real const propMiss)
inline

Set the maximal proportion of missing value allowed.

Parameters
propMissthe allowed proportion of missiong values

Definition at line 160 of file STK_CsvToArray.h.

References STK::CsvToArray< Array, Type >::propMiss(), and STK::CsvToArray< Array, Type >::propMiss_.

Member Data Documentation

◆ p_data_

template<class Array , class Type = typename Array::Type>
Array* STK::CsvToArray< Array, Type >::p_data_
private

◆ propMiss_

template<class Array , class Type = typename Array::Type>
Real STK::CsvToArray< Array, Type >::propMiss_
private

◆ rw_

template<class Array , class Type = typename Array::Type>
Rw const& STK::CsvToArray< Array, Type >::rw_
private

A reference to the TReadWriteCsv we want to export.

Definition at line 184 of file STK_CsvToArray.h.

Referenced by STK::CsvToArray< Array, Type >::run().


The documentation for this class was generated from the following file: