STK++ 1.0
STK_IVariable.h
Go to the documentation of this file.
00001 /*--------------------------------------------------------------------*/
00002 /*     Copyright (C) 2004-2007  Serge Iovleff
00003 
00004     This program is free software; you can redistribute it and/or modify
00005     it under the terms of the GNU Lesser General Public License as
00006     published by the Free Software Foundation; either version 2 of the
00007     License, or (at your option) any later version.
00008 
00009     This program is distributed in the hope that it will be useful,
00010     but WITHOUT ANY WARRANTY; without even the implied warranty of
00011     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012     GNU Lesser General Public License for more details.
00013 
00014     You should have received a copy of the GNU Lesser General Public
00015     License along with this program; if not, write to the
00016     Free Software Foundation, Inc.,
00017     59 Temple Place,
00018     Suite 330,
00019     Boston, MA 02111-1307
00020     USA
00021 
00022     Contact : Serge.Iovleff@stkpp.org
00023 */
00024 
00025 /*
00026  * Project:  stkpp::DManager
00027  * Purpose:  Define the Abstract Variable class
00028  * Author:   Serge Iovleff, serge.iovleff@stkpp.org
00029  *
00030  **/
00031 
00036 #ifndef STK_IVARIABLE_H
00037 #define STK_IVARIABLE_H
00038 
00039 #include "STK_DManager_Util.h"
00040 
00041 #include "../../STKernel/include/STK_String.h"
00042 #include "../../STKernel/include/STK_String_Util.h"
00043 #include "../../Sdk/include/STK_IContainer1D.h"
00044 
00045 namespace STK
00046 {
00047 // forward definition
00048 template <class TYPE>
00049 class Variable;
00050 
00061 class IVariable : virtual public IContainer1D
00062 {
00063   protected:
00065     const IdType type_;
00066 
00068     String name_;
00069 
00070   protected:
00072     IVariable( const IdType &type, String const& name)
00073              : type_(type)
00074              , name_(name)
00075     { ;}
00076 
00078     IVariable( const IVariable& V)
00079              : type_(V.type_)
00080              , name_(V.name_)
00081     { ;}
00082 
00083   public:
00085     typedef Variable<String> _VarStringType;
00086 
00088     virtual ~IVariable() { ;}
00089 
00091     IVariable& operator=(const IVariable &V)
00092     {
00093       name_ = V.name_;  // copy name_ of the variable
00094       return *this;
00095     }
00096 
00099     static inline String giveName( Integer const& num    = 0
00100                                  , const String  &prefix = STRING_VAR
00101                                  )
00102    { return (prefix+typeToString<Integer> (num));}
00103 
00105     inline const IdType& getType() const
00106     { return type_;}
00107 
00109     inline String const& name() const
00110     { return name_;}
00111 
00113     inline void setName( Integer const& num     = 0
00114                        , const String  &prefix  = STRING_VAR
00115                 )
00116     { name_ = (prefix+typeToString<Integer> (num));}
00117 
00119     inline void setName( String const& name)
00120     { name_ = name;}
00121 
00125     virtual void pushBackNAValues(Integer const& n=1) = 0;
00126 
00133     virtual Integer importString( const _VarStringType& V
00134                                 , std::ios_base& (*f)(std::ios_base&) = std::dec
00135                                 ) = 0;
00136 
00141     virtual const IVariable& exportString( _VarStringType& V
00142                                          , std::ios_base& (*f)(std::ios_base&)
00143                                            = std::dec
00144                                          ) const =0;
00145 
00150     virtual IVariable& operator<<( const _VarStringType& V) =0;
00151 
00155     virtual const IVariable& operator>>( _VarStringType& V) const =0;
00156 
00160     virtual IVariable* clone( bool ref = false) const = 0;
00161 };
00162 
00163 } // Namespace STK
00164 
00165 #endif //STK_IVARIABLE_H