LoadCmd.C 1.76 KB
Newer Older
Francois Gygi committed
1 2
////////////////////////////////////////////////////////////////////////////////
//
Francois Gygi committed
3 4 5 6
// Copyright (c) 2008 The Regents of the University of California
//
// This file is part of Qbox
//
Francois Gygi committed
7 8
// Qbox is distributed under the terms of the GNU General Public License
// as published by the Free Software Foundation, either version 2 of
Francois Gygi committed
9 10 11 12 13 14
// 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
// LoadCmd.C
//
////////////////////////////////////////////////////////////////////////////////
Francois Gygi committed
18
// $Id: LoadCmd.C,v 1.12 2010-02-20 23:13:02 fgygi Exp $
Francois Gygi committed
19 20 21 22 23 24 25 26 27 28 29

#include "LoadCmd.h"
#include "SampleReader.h"
#include "Sample.h"
using namespace std;

////////////////////////////////////////////////////////////////////////////////
int LoadCmd::action(int argc, char **argv)
{
  if ( (argc != 2 && argc !=3) && ui->onpe0() )
  {
30
    cout << "  use: load [-serial] uri" << endl;
Francois Gygi committed
31 32
    return 1;
  }
33

Francois Gygi committed
34 35
  int iarg = 1;
  bool serial = false;
36

Francois Gygi committed
37 38 39 40 41 42 43
  if ( !strcmp(argv[iarg],"-serial") )
  {
    serial = true;
    iarg++;
  }

  if ( ui->onpe0() )
44
    cout << " LoadCmd: loading from " << argv[iarg] << endl;
Francois Gygi committed
45

Francois Gygi committed
46 47 48 49 50
  // Reset current sample
  // cout << "atomset before reset: nsp: " << s->atoms.nsp() << endl;
  s->reset();
  // cout << "atomset after reset: nsp: " << s->atoms.nsp() << endl;

Francois Gygi committed
51
  SampleReader s_reader(s->ctxt_);
52

Francois Gygi committed
53 54 55 56 57 58 59 60 61 62 63 64 65
  try
  {
    s_reader.readSample(*s,argv[iarg],serial);
  }
  catch ( const SampleReaderException& e )
  {
    cout << " SampleReaderException caught in LoadCmd:" << endl;
    cout << e.msg << endl;
  }
  catch (...)
  {
    cout << " LoadCmd: cannot load Sample" << endl;
  }
66

Francois Gygi committed
67
  s->ctxt_.barrier();
68

Francois Gygi committed
69 70
  return 0;
}