STK++ 0.9.13
STK_IVariable.h
Go to the documentation of this file.
1/*--------------------------------------------------------------------*/
2/* Copyright (C) 2004-2016 Serge Iovleff, Université Lille 1, Inria
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2 of the
7 License, or (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with this program; if not, write to the
16 Free Software Foundation, Inc.,
17 59 Temple Place,
18 Suite 330,
19 Boston, MA 02111-1307
20 USA
21
22 Contact : S..._Dot_I..._At_stkpp_Dot_org (see copyright for ...)
23*/
24
25/*
26 * Project: stkpp::DManager
27 * Purpose: Define the Abstract Variable class
28 * Author: Serge Iovleff, S..._Dot_I..._At_stkpp_Dot_org (see copyright for ...)
29 *
30 **/
31
36#ifndef STK_IVARIABLE_H
37#define STK_IVARIABLE_H
38
39#include "STK_DManager_Util.h"
40//#include <Arrays/include/STK_Display.h>
41
42namespace STK
43{
44// forward definition
45template <class TYPE> class Variable;
46
48
61{
62 protected:
68 IVariable( Base::IdType const& type, String const& name)
69 : type_(type), name_(name)
70 {}
73 : type_(V.type_), name_(V.name_)
74 {}
75
76 public:
78 virtual ~IVariable() {}
81 {
82 name_ = V.name_; // copy name_ of the variable
83 return *this;
84 }
86 static inline String giveName( int num= 0, String const& prefix = STRING_VAR)
87 { return (prefix+typeToString<int> (num));}
89 inline const Base::IdType& getType() const { return type_;}
91 inline String const& name() const { return name_;}
93 inline void setName( int num= 0, String const& prefix = STRING_VAR)
96 inline void setName( String const& name) { name_ = name;}
98 template<class Type>
99 inline String eltAsString(int pos) const
100 { return typeToString<Type>(static_cast<Variable<Type> const&>(*this).elt(pos));}
104 virtual void exportAsString( VariableString& V) const =0;
108 virtual void pushBackNAValues(int n=1) = 0;
110 virtual int size() const = 0;
115 virtual void insertElt(int pos, int n =1) = 0;
117 virtual void clear() = 0;
122 virtual void erase(int pos, int n=1) = 0;
126 virtual void shift(int beg) = 0;
130 virtual void pushBack(int n =1) = 0;
134 virtual void popBack(int n =1) = 0;
139 virtual IVariable& operator<<( VariableString const& V) =0;
143 virtual const IVariable& operator>>( VariableString& V) const =0;
147 virtual IVariable* clone( bool ref = false) const = 0;
148};
149
150} // namespace STK
151
152#endif //STK_IVARIABLE_H
In this file we define useful constant and method specific to the DManager project.
IVariable is an Interface class for all Variables classes.
static String giveName(int num=0, String const &prefix=STRING_VAR)
virtual void popBack(int n=1)=0
Delete n last elements of the container.
virtual IVariable & operator<<(VariableString const &V)=0
Operator << : overwrite the IVariable by converting the strings contained in V into the Type.
virtual void shift(int beg)=0
New first index for the object.
virtual void pushBackNAValues(int n=1)=0
push back n NA values.
String eltAsString(int pos) const
virtual ~IVariable()
destructor.
virtual void insertElt(int pos, int n=1)=0
Insert n elements at the position pos of the container.
IVariable(const IVariable &V)
Copy constructor
void setName(String const &name)
Set the name of the variable.
virtual void erase(int pos, int n=1)=0
Delete n elements at the pos index from the container.
String name_
Name of the variable.
virtual const IVariable & operator>>(VariableString &V) const =0
Operator >> : convert the Variable V into strings.
IVariable(Base::IdType const &type, String const &name)
Default constructor.
virtual IVariable * clone(bool ref=false) const =0
IVariable & operator=(const IVariable &V)
Operator = : overwrite the IVariable with T.
virtual void clear()=0
clear Container from all elements and memory allocated.
virtual void pushBack(int n=1)=0
Add n elements at the end of the container.
void setName(int num=0, String const &prefix=STRING_VAR)
Set a default name for the variable of the form : prefix + num.
const Base::IdType & getType() const
virtual int size() const =0
const Base::IdType type_
Id Type of the variable.
virtual void exportAsString(VariableString &V) const =0
Overwrite the variable V by converting the data into strings.
String const & name() const
The MultidimRegression class allows to regress a multidimensional output variable among a multivariat...
Variable is an implementation of the Base class IVariable using The Array1D class for storing the dat...
IdType
Id for the Type of a variable.
std::basic_string< Char > String
STK fundamental type of a String.
The namespace STK is the main domain space of the Statistical ToolKit project.
Variable< String > VariableString