-// Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library 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
-// Lesser General Public License for more details.
+// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
-// See http://www.salome-platform.org/
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library 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
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
/*
* Parametre.cxx :
*
*/
-#include <map>
#include "Batch_Versatile.hxx"
#include "Batch_InvalidKeyException.hxx"
#include "Batch_Parametre.hxx"
+
using namespace std;
// Definition des membres constants statiques
def_static_MapKey(USEDRAMSIZE);
def_static_MapKey(USEDWALLTIME);
def_static_MapKey(USER);
+def_static_MapKey(WORKDIR);
+def_static_MapKey(HOMEDIR);
namespace Batch {
- // Constructeur standard
- // La map interne TypeMap possede les memes clefs que la map principale, mais les
- // valeurs associees contiennent le type des clefs de la map principale ainsi que
- // le nombre de valeurs autorisees dans l'objet Versatile (0=nombre quelconque,
- // sinon valeur precisee)
+ // Constructeur standard
+ // La map interne TypeMap possede les memes clefs que la map principale, mais les
+ // valeurs associees contiennent le type des clefs de la map principale ainsi que
+ // le nombre de valeurs autorisees dans l'objet Versatile (0=nombre quelconque,
+ // sinon valeur precisee)
Parametre::Parametre() : map< string, Versatile >()
{
TypeMap[ACCOUNT].type = STRING;
TypeMap[USER].type = STRING;
TypeMap[USER].maxelem = 1;
+
+ TypeMap[WORKDIR].type = STRING;
+ TypeMap[WORKDIR].maxelem = 1;
+
+ TypeMap[HOMEDIR].type = STRING;
+ TypeMap[HOMEDIR].maxelem = 1;
}
- // Operateur de recherche dans la map
- // Cet operateur agit sur les objets NON CONSTANTS, il autorise la modification de
- // la valeur associée à la clef car il retourne une reference non constante
+ // Operateur de recherche dans la map
+ // Cet operateur agit sur les objets NON CONSTANTS, il autorise la modification de
+ // la valeur associée à la clef car il retourne une reference non constante
Versatile & Parametre::operator [] (const string & mk)
{
- // On controle que la clef est valide
+ // On controle que la clef est valide
if (TypeMap.find(mk) == TypeMap.end()) throw InvalidKeyException(mk.c_str());
- // On recherche la valeur associee...
+ // On recherche la valeur associee...
Versatile & V = map< string, Versatile >::operator [] (mk);
- // ... et on l'initialise systematiquement
- // ATTENTION : si un probleme de type survient (ie, on stocke une valeur d'un type
- // different de celui inscrit dans TypeMap) une exception TypeMismatchException est
- // levee
+ // ... et on l'initialise systematiquement
+ // ATTENTION : si un probleme de type survient (ie, on stocke une valeur d'un type
+ // different de celui inscrit dans TypeMap) une exception TypeMismatchException est
+ // levee
V.setName(mk);
V.setType(TypeMap[mk].type);
V.setMaxSize(TypeMap[mk].maxelem);
return V;
}
- // Operateur de recherche dans la map
- // Cet operateur agit sur les objets CONSTANTS
+ // Operateur de recherche dans la map
+ // Cet operateur agit sur les objets CONSTANTS
const Versatile & Parametre::operator [] (const string & mk) const
{
- // On controle que la clef est valide
+ // On controle que la clef est valide
if (TypeMap.find(mk) == TypeMap.end()) throw InvalidKeyException(mk.c_str());
- // On recherche la valeur associee
- Parametre::const_iterator it = find(mk);
+ // On recherche la valeur associee
+ Parametre::const_iterator it = find(mk);
+ if (it == end()) throw InvalidKeyException(mk.c_str());
const Versatile & V = (*it).second;
return V;
}
- // Operateur d'affectation
+ // Operateur d'affectation
Parametre & Parametre::operator =(const Parametre & PM)
{
- // On ne reaffecte pas l'objet a lui-meme, sinon aie, aie, aie
+ // On ne reaffecte pas l'objet a lui-meme, sinon aie, aie, aie
if (this == &PM) return *this;
- // On efface toute la map
+ // On efface toute la map
erase(begin(), end());
- // On recopie la map interne
- // Meme si cela ne sert a rien pour le moment car les maps internes sont identiques,
- // il n'est pas exclu que dans un avenir proche elles puissent etre differentes
+ // On recopie la map interne
+ // Meme si cela ne sert a rien pour le moment car les maps internes sont identiques,
+ // il n'est pas exclu que dans un avenir proche elles puissent etre differentes
(*this).TypeMap = PM.TypeMap;
- // On recree la structure interne de la map avec les valeurs de celle passee en argument
+ // On recree la structure interne de la map avec les valeurs de celle passee en argument
Parametre::const_iterator it;
for(it=PM.begin(); it!=PM.end(); it++)
insert(make_pair( (*it).first ,
return *this;
}
- // Constructeur par recopie
+ // Constructeur par recopie
Parametre::Parametre(const Parametre & PM)
{
- // inutile car l'objet est vierge : il vient d'etre cree
- // On efface toute la map
+ // inutile car l'objet est vierge : il vient d'etre cree
+ // On efface toute la map
// erase(begin(), end());
- // On recopie la map interne
+ // On recopie la map interne
(*this).TypeMap = PM.TypeMap;
- // On cree la structure interne de la map avec les valeurs de celle passee en argument
- Parametre::const_iterator it;
- for(it=PM.begin();
- it!=PM.end();
- it++)
+ // On cree la structure interne de la map avec les valeurs de celle passee en argument
+ Parametre::const_iterator it;
+ for(it=PM.begin();
+ it!=PM.end();
+ it++)
insert(
- make_pair(
- (*it).first ,
- Versatile( (*it).second)
- ) );
+ make_pair(
+ (*it).first ,
+ Versatile( (*it).second)
+ ) );
}
// map< string, TypeParam > Parametre::getTypeMap() const