1 // Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
25 * Auteur : Ivan DUTKA-MALEN - EDF R&D
26 * Date : Septembre 2003
31 #include "Batch_Versatile.hxx"
32 #include "Batch_InvalidKeyException.hxx"
33 #include "Batch_ParameterTypeMap.hxx"
34 #include "Batch_Parametre.hxx"
40 // Constructeur standard
41 Parametre::Parametre() : map< string, Versatile >()
45 // Operateur de recherche dans la map
46 // Cet operateur agit sur les objets NON CONSTANTS, il autorise la modification de
47 // la valeur associ�e � la clef car il retourne une reference non constante
48 Versatile & Parametre::operator [] (const string & mk)
50 // On controle que la clef est valide
51 if (!ParameterTypeMap::getInstance().hasKey(mk)) throw InvalidKeyException(mk);
53 // On recherche la valeur associee...
54 Versatile & V = map< string, Versatile >::operator [] (mk);
56 // ... et on l'initialise systematiquement
57 // ATTENTION : si un probleme de type survient (ie, on stocke une valeur d'un type
58 // different de celui inscrit dans TypeMap) une exception TypeMismatchException est
61 V.setType(ParameterTypeMap::getInstance()[mk].type);
62 V.setMaxSize(ParameterTypeMap::getInstance()[mk].maxelem);
67 // Operateur de recherche dans la map
68 // Cet operateur agit sur les objets CONSTANTS
69 const Versatile & Parametre::operator [] (const string & mk) const
71 // On controle que la clef est valide
72 if (!ParameterTypeMap::getInstance().hasKey(mk)) throw InvalidKeyException(mk);
74 // On recherche la valeur associee
75 Parametre::const_iterator it = find(mk);
76 if (it == end()) throw InvalidKeyException(mk);
77 const Versatile & V = (*it).second;
82 // Operateur d'affectation
83 Parametre & Parametre::operator =(const Parametre & PM)
85 // On ne reaffecte pas l'objet a lui-meme, sinon aie, aie, aie
86 if (this == &PM) return *this;
88 // On efface toute la map
89 erase(begin(), end());
91 // On recree la structure interne de la map avec les valeurs de celle passee en argument
92 Parametre::const_iterator it;
93 for(it=PM.begin(); it!=PM.end(); it++)
94 insert(make_pair((*it).first, Versatile((*it).second)));
99 // Constructeur par recopie
100 Parametre::Parametre(const Parametre & PM) : map< string, Versatile >()
102 // On cree la structure interne de la map avec les valeurs de celle passee en argument
103 Parametre::const_iterator it;
104 for(it=PM.begin(); it!=PM.end(); it++)
105 insert(make_pair((*it).first, Versatile((*it).second)));