sample.h
Go to the documentation of this file.
00001 // $Id: sample.h 30606 2009-10-02 10:01:02Z tdelaet $
00002 // Copyright (C) 2002 Klaas Gadeyne <first dot last at gmail dot com>
00003  /***************************************************************************
00004  *   This library is free software; you can redistribute it and/or         *
00005  *   modify it under the terms of the GNU General Public                   *
00006  *   License as published by the Free Software Foundation;                 *
00007  *   version 2 of the License.                                             *
00008  *                                                                         *
00009  *   As a special exception, you may use this file as part of a free       *
00010  *   software library without restriction.  Specifically, if other files   *
00011  *   instantiate templates or use macros or inline functions from this     *
00012  *   file, or you compile this file and link it with other files to        *
00013  *   produce an executable, this file does not by itself cause the         *
00014  *   resulting executable to be covered by the GNU General Public          *
00015  *   License.  This exception does not however invalidate any other        *
00016  *   reasons why the executable file might be covered by the GNU General   *
00017  *   Public License.                                                       *
00018  *                                                                         *
00019  *   This library is distributed in the hope that it will be useful,       *
00020  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00021  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU     *
00022  *   Lesser General Public License for more details.                       *
00023  *                                                                         *
00024  *   You should have received a copy of the GNU General Public             *
00025  *   License along with this library; if not, write to the Free Software   *
00026  *   Foundation, Inc., 59 Temple Place,                                    *
00027  *   Suite 330, Boston, MA  02111-1307  USA                                *
00028  *                                                                         *
00029  ***************************************************************************/
00030 #ifndef SAMPLE_H
00031 #define SAMPLE_H
00032 
00033 // Adjust this to absolute path!
00034 // Using <> makes that the g++ standard implementation of vector is chosen!
00035 #include "../bfl_err.h"
00036 #include "../wrappers/matrix/vector_wrapper.h"
00037 #include "../wrappers/matrix/matrix_wrapper.h"
00038 #include <iostream>
00039 
00040 namespace BFL
00041 {
00042   using namespace std;
00043 
00047   template <typename T> class Sample
00048     {
00049     protected:
00051       T Value;
00052 
00053     public:
00055 
00059       Sample (unsigned int dimension = 0);
00060 
00062       virtual ~Sample();
00063 
00065       Sample ( const Sample<T> & my_sample );
00066 
00068       T& ValueGet (  ) ;
00069 
00071       const T& ValueGet (  ) const;
00072 
00073       // dimension get
00074       unsigned int DimensionGet () const;
00075 
00076       // dimension set
00077       void DimensionSet (unsigned int dim);
00078 
00080 
00083       void ValueSet ( const T& value );
00084 
00086 
00090       template <typename S> friend ostream & operator<< (ostream & stream,
00091                                                          Sample<S> & my_sample);
00092 
00093       template <typename S> friend istream & operator>> (istream & stream,
00094                                                          Sample<S> & my_sample);
00096       Sample & operator= (const Sample & my_sample);
00097 
00098     };
00099 
00100 
00101 
00102 
00103 
00104 
00105 
00106 
00107   // constructor
00108   template <typename T> Sample<T>::Sample (unsigned int dimension)
00109     {};
00110 
00111 
00112   // destructor
00113   template <typename T> Sample<T>::~Sample( )
00114     {};
00115 
00116 
00117   // copy constructor
00118   template <typename T> Sample<T>::Sample ( const Sample & my_sample )
00119     {
00120       Value     = my_sample.ValueGet();
00121     }
00122 
00123 
00124   // set value
00125   template <typename T> void Sample<T>::ValueSet (const T& value)
00126     {
00127        Value = value;
00128     }
00129 
00130 
00131   // get value
00132   template <typename T> T& Sample<T>::ValueGet (  )
00133     {
00134       return Value;
00135     }
00136 
00137 
00138   // get value
00139   template <typename T> const T& Sample<T>::ValueGet (  )  const
00140     {
00141       return Value;
00142     }
00143 
00144   // get dimension
00145   template <typename T> unsigned int Sample<T>::DimensionGet (  )  const
00146     {
00147       return 0;
00148     }
00149 
00150   // set dimension
00151   template <typename T> void Sample<T>::DimensionSet (unsigned int dim)
00152     {}
00153 
00154   // stream
00155   template <typename S> ostream & operator<< (ostream & stream, Sample<S> & my_sample)
00156     {
00157       stream << my_sample.ValueGet() << endl;
00158       return stream;
00159     }
00160 
00161   template <typename S> istream & operator>> (istream & stream, Sample<S> & my_sample)
00162     {
00163         S value;
00164         stream >> value;
00165         my_sample.ValueSet(value);
00166         return stream; 
00167     }
00168 
00169   // operator =
00170   template <typename T> Sample<T> & Sample<T>::operator= ( const Sample<T> & my_sample)
00171     {
00172       Value     = my_sample.ValueGet();
00173       return *this;
00174     }
00175 
00176 
00177 
00178 } // End namespace BFL
00179 
00180 #include "sample.cpp"
00181 
00182 #endif


bfl
Author(s): Klaas Gadeyne, Wim Meeussen, Tinne Delaet and many others. See web page for a full contributor list. ROS package maintained by Wim Meeussen.
autogenerated on Fri Aug 28 2015 10:10:21