• Main Page
  • Modules
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

maptypes.h

Go to the documentation of this file.
00001 /// @addtogroup unifexp
00002 /// @{
00003 
00004 /////////////////////////////////////////////////////////////////////////////
00005 ///
00006 /// @file maptypes.h
00007 ///
00008 /// This file contains the definition of a class which gathers all the
00009 /// available map types and allows to select a map class object by its name.
00010 ///
00011 /// @author Pawel Pilarczyk
00012 ///
00013 /////////////////////////////////////////////////////////////////////////////
00014 
00015 // Copyright (C) 2007 by Pawel Pilarczyk.
00016 //
00017 // This file is part of my research program package.  This is free software;
00018 // you can redistribute it and/or modify it under the terms of the GNU
00019 // General Public License as published by the Free Software Foundation;
00020 // either version 2 of the License, or (at your option) any later version.
00021 //
00022 // This software is distributed in the hope that it will be useful,
00023 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00024 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00025 // GNU General Public License for more details.
00026 //
00027 // You should have received a copy of the GNU General Public License along
00028 // with this software; see the file "license.txt".  If not, write to the
00029 // Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
00030 // MA 02111-1307, USA.
00031 
00032 // Started on August 22, 2007. Last revision: August 23, 2007.
00033 
00034 #ifndef _maptypes_h_
00035 #define _maptypes_h_
00036 
00037 // some standard C++ headers
00038 #include <vector>
00039 #include <string>
00040 #include <iostream>
00041 
00042 // the abstract map type header
00043 #include "maptype.h"
00044 
00045 // all the available map type headers
00046 #include "mapquad.h"
00047 #include "mapquadi.h"
00048 #include "mapunim.h"
00049 #include "mapunimi.h"
00050 #include "mapcub.h"
00051 #include "mapcubi.h"
00052 
00053 // ADD YOUR HEADERS HERE (and don't forget to add your objects below)
00054 
00055 
00056 
00057 namespace unifexp {
00058 
00059 // --------------------------------------------------
00060 // ------------------- map types --------------------
00061 // --------------------------------------------------
00062 
00063 /// This class gathers all the available map types and allows
00064 /// to select a map class object by its name.
00065 template <class numType>
00066 class mapTypes
00067 {
00068 public:
00069         /// The constructor.
00070         mapTypes ();
00071 
00072         /// The destructor.
00073         ~mapTypes ();
00074 
00075         /// Retrieves a pointer to a map object with the given name.
00076         /// Returns 0 if such an object cannot be found.
00077         mapType<numType> *get (const std::string &name) const;
00078 
00079         /// Fills in a vector of text strings with the names
00080         /// of all the available map objects.
00081         void getNames (std::vector<std::string> &names) const;
00082 
00083 private:
00084         /// The copy constructor is not allowed.
00085         mapTypes (const mapTypes<numType> &);
00086 
00087         /// The assignment operator is not allowed.
00088         mapTypes<numType> &operator = (const mapTypes<numType> &);
00089 
00090         /// A vector of all the map objects to choose from.
00091         /// The objects must be created with the 'new' operator.
00092         /// They are automatically deallocated by the destructor.
00093         std::vector<mapType<numType> *> objects;
00094 
00095 }; /* class mapTypes */
00096 
00097 // --------------------------------------------------
00098 
00099 template <class numType>
00100 inline mapTypes<numType>::mapTypes ()
00101 {
00102         // add objects of all map types
00103         objects. push_back (new mapQuadr<numType> ());
00104         objects. push_back (new mapQuadrIntv<numType> ());
00105         objects. push_back (new mapUnimodal<numType> (1.0));
00106         objects. push_back (new mapUnimodal<numType> (3.0 / 2));
00107         objects. push_back (new mapUnimodal<numType> (2.0));
00108         objects. push_back (new mapUnimodal<numType> (5.0 / 2));
00109         objects. push_back (new mapUnimodalIntv<numType> (1.0));
00110         objects. push_back (new mapUnimodalIntv<numType> (3.0, 2.0));
00111         objects. push_back (new mapUnimodalIntv<numType> (2.0));
00112         objects. push_back (new mapUnimodalIntv<numType> (5.0, 2.0));
00113         objects. push_back (new mapCubic<numType> ());
00114         objects. push_back (new mapCubicIntv<numType> ());
00115 
00116         // ADD YOUR OBJECTS HERE
00117 
00118         
00119         return;
00120 } /* mapTypes::mapTypes */
00121 
00122 template <class numType>
00123 inline mapTypes<numType>::~mapTypes ()
00124 {
00125         for (typename std::vector<mapType<numType> *>::iterator iter =
00126                 objects. begin (); iter != objects. end (); ++ iter)
00127         {
00128                 delete *iter;
00129         }
00130         return;
00131 } /* mapTypes::~mapTypes */
00132 
00133 template <class numType>
00134 inline mapTypes<numType>::mapTypes (const mapTypes<numType> &)
00135 {
00136         throw "Copy constructor not implemented for the map types class.";
00137         return;
00138 } /* mapTypes::mapTypes */
00139 
00140 template <class numType>
00141 inline mapTypes<numType> &mapTypes<numType>::operator =
00142         (const mapTypes<numType> &)
00143 {
00144         throw "Assignment operator not implemented for the map types class.";
00145         return *this;
00146 } /* mapTypes::operator = */
00147 
00148 template <class numType>
00149 inline mapType<numType> *mapTypes<numType>::get (const std::string &name)
00150         const
00151 {
00152         for (typename std::vector<mapType<numType> *>::const_iterator
00153                 iter = objects. begin (); iter != objects. end (); ++ iter)
00154         {
00155                 if ((*iter) -> name () == name)
00156                         return *iter;
00157         }
00158         return 0;
00159 } /* mapTypes::get */
00160 
00161 template <class numType>
00162 inline void mapTypes<numType>::getNames (std::vector<std::string> &names)
00163         const
00164 {
00165         for (typename std::vector<mapType<numType> *>::const_iterator
00166                 iter = objects. begin (); iter != objects. end (); ++ iter)
00167         {
00168                 names. push_back ((*iter) -> name ());
00169         }
00170         return;
00171 } /* mapTypes::getNames */
00172 
00173 
00174 } // namespace unifexp
00175 
00176 #endif // _maptypes_h_
00177 
00178 /// @}
00179 

Generated on Sun Feb 3 2013 12:40:31 for The Uniform Expansion Software by  doxygen 1.7.2