STK++ 0.9.13
STK::IVariable Class Referenceabstract

IVariable is an Interface class for all Variables classes. More...

#include <STK_IVariable.h>

Inheritance diagram for STK::IVariable:
Inheritance graph

Public Member Functions

virtual ~IVariable ()
 destructor.
 
IVariableoperator= (const IVariable &V)
 Operator = : overwrite the IVariable with T.
 
const Base::IdTypegetType () const
 
String constname () const
 
void setName (int num=0, String const &prefix=STRING_VAR)
 Set a default name for the variable of the form : prefix + num.
 
void setName (String const &name)
 Set the name of the variable.
 
template<class Type >
String eltAsString (int pos) const
 
virtual void exportAsString (VariableString &V) const =0
 Overwrite the variable V by converting the data into strings.
 
virtual void pushBackNAValues (int n=1)=0
 push back n NA values.
 
virtual int size () const =0
 
virtual void insertElt (int pos, int n=1)=0
 Insert n elements at the position pos of the container.
 
virtual void clear ()=0
 clear Container from all elements and memory allocated.
 
virtual void erase (int pos, int n=1)=0
 Delete n elements at the pos index from the container.
 
virtual void shift (int beg)=0
 New first index for the object.
 
virtual void pushBack (int n=1)=0
 Add n elements at the end of the container.
 
virtual void popBack (int n=1)=0
 Delete n last elements of the container.
 
virtual IVariableoperator<< (VariableString const &V)=0
 Operator << : overwrite the IVariable by converting the strings contained in V into the Type.
 
virtual const IVariableoperator>> (VariableString &V) const =0
 Operator >> : convert the Variable V into strings.
 
virtual IVariableclone (bool ref=false) const =0
 

Static Public Member Functions

static String giveName (int num=0, String const &prefix=STRING_VAR)
 

Protected Member Functions

 IVariable (Base::IdType const &type, String const &name)
 Default constructor.
 
 IVariable (const IVariable &V)
 Copy constructor

 

Protected Attributes

const Base::IdType type_
 Id Type of the variable.
 
String name_
 Name of the variable.
 

Detailed Description

IVariable is an Interface class for all Variables classes.

A Variable have a name and a type, the implementation have to choose some one-dimensional container class derived from IContainer2D for storing the data.

The pure virtual function defined in this class are the one needed by the DataFrame class which handle an heterogeneous collection of Variable.

Definition at line 60 of file STK_IVariable.h.

Constructor & Destructor Documentation

◆ IVariable() [1/2]

STK::IVariable::IVariable ( Base::IdType const type,
String const name 
)
inlineprotected

Default constructor.

Definition at line 68 of file STK_IVariable.h.

69 : type_(type), name_(name)
70 {}
String name_
Name of the variable.
const Base::IdType type_
Id Type of the variable.
String const & name() const

◆ IVariable() [2/2]

STK::IVariable::IVariable ( const IVariable V)
inlineprotected

Copy constructor

Definition at line 72 of file STK_IVariable.h.

73 : type_(V.type_), name_(V.name_)
74 {}

◆ ~IVariable()

virtual STK::IVariable::~IVariable ( )
inlinevirtual

destructor.

Definition at line 78 of file STK_IVariable.h.

78{}

Member Function Documentation

◆ clear()

virtual void STK::IVariable::clear ( )
pure virtual

clear Container from all elements and memory allocated.

Implemented in STK::Variable< Type_ >, and STK::Variable< Real >.

◆ clone()

virtual IVariable * STK::IVariable::clone ( bool  ref = false) const
pure virtual
Returns
a ptr on a copy of the object.
Parameters
reftrue if we don't want to copy the data

Implemented in STK::Variable< Type_ >, and STK::Variable< Real >.

Referenced by STK::DataFrame::insertDataFrame(), and STK::DataFrame::pushBackDataFrame().

◆ eltAsString()

template<class Type >
String STK::IVariable::eltAsString ( int  pos) const
inline
Returns
the element pos as a String

Definition at line 99 of file STK_IVariable.h.

100 { return typeToString<Type>(static_cast<Variable<Type> const&>(*this).elt(pos));}

◆ erase()

virtual void STK::IVariable::erase ( int  pos,
int  n = 1 
)
pure virtual

Delete n elements at the pos index from the container.

Parameters
posindex where to delete elements
nnumber of elements to delete (default 1)

Implemented in STK::Variable< Type_ >, and STK::Variable< Real >.

Referenced by STK::DataFrame::eraseRows().

◆ exportAsString()

virtual void STK::IVariable::exportAsString ( VariableString V) const
pure virtual

Overwrite the variable V by converting the data into strings.

Parameters
VVariable of String

Referenced by STK::ExportToCsv::ExportToCsv().

◆ getType()

const Base::IdType & STK::IVariable::getType ( ) const
inline
Returns
the type of the variable.

Definition at line 89 of file STK_IVariable.h.

89{ return type_;}

References type_.

◆ giveName()

static String STK::IVariable::giveName ( int  num = 0,
String const prefix = STRING_VAR 
)
inlinestatic
Returns
a default name for a variable of the form : prefix + num.

Definition at line 86 of file STK_IVariable.h.

87 { return (prefix+typeToString<int> (num));}

◆ insertElt()

virtual void STK::IVariable::insertElt ( int  pos,
int  n = 1 
)
pure virtual

Insert n elements at the position pos of the container.

Parameters
posindex where to insert elements
nnumber of elements to insert (default 1)

Implemented in STK::Variable< Type_ >, and STK::Variable< Real >.

Referenced by STK::DataFrame::insertRows().

◆ name()

String const & STK::IVariable::name ( ) const
inline
Returns
the name of the variable.

Definition at line 91 of file STK_IVariable.h.

91{ return name_;}

References name_.

Referenced by STK::Variable< Type_ >::maxLength(), and setName().

◆ operator<<()

virtual IVariable & STK::IVariable::operator<< ( VariableString const V)
pure virtual

Operator << : overwrite the IVariable by converting the strings contained in V into the Type.

Parameters
Vthe Variable of string to import

◆ operator=()

IVariable & STK::IVariable::operator= ( const IVariable V)
inline

Operator = : overwrite the IVariable with T.


Definition at line 80 of file STK_IVariable.h.

81 {
82 name_ = V.name_; // copy name_ of the variable
83 return *this;
84 }

References name_.

◆ operator>>()

virtual const IVariable & STK::IVariable::operator>> ( VariableString V) const
pure virtual

Operator >> : convert the Variable V into strings.

Parameters
VVariable of String

◆ popBack()

virtual void STK::IVariable::popBack ( int  n = 1)
pure virtual

Delete n last elements of the container.

Parameters
nnumber of elements to delete

Implemented in STK::Variable< Type_ >, and STK::Variable< Real >.

Referenced by STK::DataFrame::popBackRows().

◆ pushBack()

virtual void STK::IVariable::pushBack ( int  n = 1)
pure virtual

Add n elements at the end of the container.

Parameters
nnumber of elements to add

Implemented in STK::Variable< Type_ >, and STK::Variable< Real >.

Referenced by STK::DataFrame::pushBackRows().

◆ pushBackNAValues()

virtual void STK::IVariable::pushBackNAValues ( int  n = 1)
pure virtual

◆ setName() [1/2]

void STK::IVariable::setName ( int  num = 0,
String const prefix = STRING_VAR 
)
inline

Set a default name for the variable of the form : prefix + num.


Definition at line 93 of file STK_IVariable.h.

94 { name_ = (prefix+typeToString<int> (num));}

References name_.

◆ setName() [2/2]

void STK::IVariable::setName ( String const name)
inline

Set the name of the variable.


Definition at line 96 of file STK_IVariable.h.

96{ name_ = name;}

References name(), and name_.

◆ shift()

virtual void STK::IVariable::shift ( int  beg)
pure virtual

New first index for the object.

Parameters
begthe index of the first column to set

Implemented in STK::Variable< Type_ >, and STK::Variable< Real >.

Referenced by STK::DataFrame::insertDataFrame(), STK::DataFrame::insertVariable(), STK::DataFrame::pushBackDataFrame(), STK::DataFrame::pushBackVariable(), and STK::DataFrame::shift().

◆ size()

virtual int STK::IVariable::size ( ) const
pure virtual
Returns
the number of sample in the variable

Implemented in STK::Variable< Type_ >, and STK::Variable< Real >.

Referenced by STK::DataFrame::insertVariable(), and STK::DataFrame::pushBackVariable().

Member Data Documentation

◆ name_

String STK::IVariable::name_
protected

Name of the variable.

Definition at line 66 of file STK_IVariable.h.

Referenced by STK::Variable< Type_ >::move(), name(), operator=(), STK::Variable< Type_ >::operator=(), setName(), and setName().

◆ type_

const Base::IdType STK::IVariable::type_
protected

Id Type of the variable.

Definition at line 64 of file STK_IVariable.h.

Referenced by getType().


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