/*! \file valmap.h * \brief map element values (prototypes) * * ---------------------------------------------------------------------------- * * $Id: valmap.h,v 1.6 2006-03-28 16:03:05 tforb Exp $ * \author Thomas Forbriger * \date 20/03/2005 * * map element values (prototypes) * * ---- * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * ---- * * Copyright (c) 2005 by Thomas Forbriger (BFO Schiltach) * * REVISIONS and CHANGES * - 20/03/2005 V1.0 Thomas Forbriger * * ============================================================================ */ // include guard #ifndef AFF_VALMAP_H_VERSION #define AFF_VALMAP_H_VERSION \ "AFF_VALMAP_H V1.0 " #define AFF_VALMAP_H_CVSID \ "$Id: valmap.h,v 1.6 2006-03-28 16:03:05 tforb Exp $" #include #include namespace aff { namespace func { namespace util { /*! Utility class to map values using a std::map * * This class should be used together with the * aff::func::util::mapvalues() function template. * * \param T1 source value type * \param T2 target value type */ template class Mapvalmap { public: typedef T1 Tinvalue; typedef T2 Toutvalue; typedef std::map Tmap; //! initialize member data Mapvalmap(const Tmap& m): Mmap(m) { } //! map another value Toutvalue operator() (Tinvalue v) const { return(Mmap[v]); } private: mutable Tmap Mmap; }; // class Mapvalmap } // namespace util /*----------------------------------------------------------------------*/ /*! Function template to map container contents to values of a different * type * * \param C any container class like aff::Array * \param M a std::map that defines source and target type * * \param c any container of values to be mapped * \return container of same shape as c but with mapped values * * \sa aff::func::util::mapvaues, aff::func::util::Mapvalmap */ template