ForEachProfile.h
1 //-*-C++-*-
2 /***************************************************************************
3  *
4  * Copyright (C) 2016 by Willem van Straten
5  * Licensed under the Academic Free License version 2.1
6  *
7  ***************************************************************************/
8 
9 // psrchive/More/General/Pulsar/ForEachProfile.h
10 
11 #ifndef __Pulsar_ForEachProfile_h
12 #define __Pulsar_ForEachProfile_h
13 
14 #include "Pulsar/Archive.h"
15 #include <string>
16 #include <vector>
17 
18 namespace Pulsar {
19 
20  class ForEachProfile
21  {
22  std::string subint;
23  std::string chan;
24  std::string pol;
25 
26  public:
27 
28  ForEachProfile (std::vector<std::string>& tokens) { parse(tokens); }
29 
31 
32  void parse (std::vector<std::string>& tokens);
33 
34  // call the Profile member function with the specified argument
35  template<typename Method, typename Argument>
36  void operator () (Archive* archive, Method method, Argument argument)
37  {
38  std::vector<unsigned> subint_i;
39  TextInterface::parse_indeces (subint_i, subint, archive->get_nsubint());
40 
41  //std::cerr << "subint size=" << subint_i.size() << std::endl;
42 
43  std::vector<unsigned> chan_i;
44  TextInterface::parse_indeces (chan_i, chan, archive->get_nchan());
45 
46  //std::cerr << "chan size=" << chan_i.size() << std::endl;
47 
48  std::vector<unsigned> pol_i;
49  TextInterface::parse_indeces (pol_i, pol, archive->get_npol());
50 
51  //std::cerr << "pol size=" << pol_i.size() << std::endl;
52 
53  for (unsigned isub=0; isub < subint_i.size(); isub++)
54  for (unsigned ipol=0; ipol < pol_i.size(); ipol++)
55  for (unsigned ichan=0; ichan < chan_i.size(); ichan++)
56  {
57  Profile* profile = archive->get_Profile (subint_i[isub],
58  pol_i[ipol],
59  chan_i[ichan]);
60  (profile->*method)(argument);
61  }
62  }
63  };
64 
65 }
66 
67 #endif
Defines the PSRCHIVE library.
Definition: CalSource.h:17

Generated using doxygen 1.8.17