SampleHandler.C 3.1 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 29
// SampleHandler.C
//
////////////////////////////////////////////////////////////////////////////////

#include "SampleHandler.h"
#include "Sample.h"
#include "AtomSetHandler.h"
#include "WavefunctionHandler.h"
#include "StrX.h"
using namespace xercesc;
#include <iostream>
#include <cassert>
using namespace std;

////////////////////////////////////////////////////////////////////////////////
30
SampleHandler::SampleHandler(Sample& s, DoubleMatrix& gfdata) :
31
  s_(s), gfdata_(gfdata), current_gfdata_pos(0) {}
Francois Gygi committed
32 33 34 35 36 37 38 39

////////////////////////////////////////////////////////////////////////////////
SampleHandler::~SampleHandler() {}

////////////////////////////////////////////////////////////////////////////////
void SampleHandler::startElement(const XMLCh* const uri,
  const XMLCh* const localname, const XMLCh* const qname,
  const Attributes& attributes)
40
{
Francois Gygi committed
41 42 43 44 45 46 47
  // cout << " SampleHandler::startElement " << StrX(qname) << endl;
}

////////////////////////////////////////////////////////////////////////////////
void SampleHandler::endElement(const XMLCh* const uri,
  const XMLCh* const localname, const XMLCh* const qname, string& content)
{
48 49
  // istringstream stst(st);
  // string locname(XMLString::transcode(localname));
Francois Gygi committed
50 51 52 53 54
  // cout << " SampleHandler::endElement " << locname << endl;
}

////////////////////////////////////////////////////////////////////////////////
StructureHandler* SampleHandler::startSubHandler(const XMLCh* const uri,
55
    const XMLCh* const localname, const XMLCh* const qname,
Francois Gygi committed
56 57 58 59 60
    const Attributes& attributes)
{
  // check if element qname can be processed by another StructureHandler
  // If it can, return a pointer to the StructureHandler, otherwise return 0
  // cout << " SampleHandler::startSubHandler " << StrX(qname) << endl;
61

Francois Gygi committed
62 63 64 65 66 67 68 69
  string qnm = XMLString::transcode(qname);
  if ( qnm == "atomset" )
  {
    return new AtomSetHandler(s_.atoms);
  }
  else if ( qnm == "wavefunction" )
  {
    read_wf = true;
70
    return new WavefunctionHandler(s_.wf,gfdata_,current_gfdata_pos);
Francois Gygi committed
71 72 73 74
  }
  else if ( qnm == "wavefunction_velocity" )
  {
    read_wfv = true;
75 76
    assert(read_wf);
    s_.wfv = new Wavefunction(s_.wf);
77
    return new WavefunctionHandler(*s_.wfv,gfdata_,current_gfdata_pos);
Francois Gygi committed
78 79 80 81 82 83 84 85 86
  }
  else
  {
    return 0;
  }
}

////////////////////////////////////////////////////////////////////////////////
void SampleHandler::endSubHandler(const XMLCh* const uri,
87
    const XMLCh* const localname, const XMLCh* const qname,
Francois Gygi committed
88 89 90 91 92
    const StructureHandler* const subHandler)
{
  // cout << " SampleHandler::endSubHandler " << StrX(qname) << endl;
  delete subHandler;
}