LoadCmd.C 1.7 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 18 19 20 21 22 23 24 25 26 27 28
// LoadCmd.C
//
////////////////////////////////////////////////////////////////////////////////

#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() )
  {
29
    cout << "  use: load [-serial] uri" << endl;
Francois Gygi committed
30 31
    return 1;
  }
32

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

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

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

Francois Gygi committed
45 46 47 48 49
  // 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
50
  SampleReader s_reader(s->ctxt_);
51

Francois Gygi committed
52 53 54 55 56 57 58 59 60 61 62 63 64
  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;
  }
65

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

Francois Gygi committed
68 69
  return 0;
}