SpeciesCmd.C 1.66 KB
Newer Older
Francois Gygi committed
1 2
////////////////////////////////////////////////////////////////////////////////
//
Francois Gygi committed
3 4 5 6 7 8 9 10 11 12 13 14
// Copyright (c) 2008 The Regents of the University of California
//
// This file is part of Qbox
//
// Qbox is distributed 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.
// See the file COPYING in the root directory of this distribution
// or <http://www.gnu.org/licenses/>.
//
////////////////////////////////////////////////////////////////////////////////
//
Francois Gygi committed
15 16 17
// SpeciesCmd.C
//
////////////////////////////////////////////////////////////////////////////////
Francois Gygi committed
18
// $Id: SpeciesCmd.C,v 1.11 2008-08-13 06:39:43 fgygi Exp $
Francois Gygi committed
19 20 21

#include "SpeciesCmd.h"
#include "SpeciesReader.h"
22
#include "Species.h"
Francois Gygi committed
23 24 25 26 27 28 29 30 31 32
using namespace std;

class Species;

////////////////////////////////////////////////////////////////////////////////
int SpeciesCmd::action(int argc, char **argv)
{
  if ( argc != 3 )
  {
    if ( ui->onpe0() )
33
      cout << "  Use: species name uri" << endl;
Francois Gygi committed
34 35
    return 1;
  }
36

Francois Gygi committed
37
  if ( ui->onpe0() )
38 39
    cout << "  SpeciesCmd: defining species " << argv[1]
         << " as " << argv[2] << endl;
Francois Gygi committed
40

Francois Gygi committed
41
  SpeciesReader sp_reader(s->ctxt_);
42

Francois Gygi committed
43
  Species* sp = new Species(s->ctxt_,argv[1]);
44

Francois Gygi committed
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
  try
  {
    sp_reader.readSpecies(*sp,argv[2]);
    sp_reader.bcastSpecies(*sp);
    s->atoms.addSpecies(sp,argv[1]);
  }
  catch ( const SpeciesReaderException& e )
  {
    cout << " SpeciesReaderException caught in SpeciesCmd" << endl;
    cout << " SpeciesReaderException: cannot define Species" << endl;
  }
  catch (...)
  {
    cout << " SpeciesCmd: cannot define Species" << endl;
  }
60

Francois Gygi committed
61 62
  return 0;
}