source: Sophya/trunk/SophyaProg/PrgUtil/scanppf.cc@ 3811

Last change on this file since 3811 was 3619, checked in by cmv, 16 years ago

add various #include<> for g++ 4.3 (jaunty 9.04), cmv 05/05/2009

File size: 3.9 KB
RevLine 
[1306]1#include <stdio.h>
2#include <stdlib.h>
[3619]3#include <string.h>
[1306]4#include <typeinfo>
[2322]5#include <iostream>
[1306]6#include <string>
7
[2615]8#include "sopnamsp.h"
[1306]9#include "ppersist.h"
10#include "anydataobj.h"
11#include "sambainit.h"
[2636]12#include "histinit.h"
[1306]13
14
[1441]15/*!
16 \defgroup PrgUtil PrgUtil module
17 This module contains simple programs to perform various utility tasks:
18 <UL>
19 <LI> scanppf : Check and scan PPF files (scanppf.cc)
20 <LI> scanfits : Check and scan FITS files (scanfits.cc)
21 <LI> runcxx : Compile and run simple C++ code using SOPHYA (runcxx.cc)
22 </UL>
23*/
24
25/*!
26 \ingroup PrgUtil
27 \file scanppf.cc
28 \brief \b scanppf: Check and scan PPF files
29
30 \verbatim
31
32 csh> scanppf -h
[2662]33 PIOPersist::Initialize() Starting Sophya Persistence management service
[3028]34SOPHYA Version 2.0 Revision 0 (V_Jul2006) -- Jul 17 2006 14:13:27 cxx
[2662]35 Usage: scanppf [flags] filename
[3028]36 flags = -s -n -a0 -a1 -a2 -a3 -lh -lho -lmod
[2662]37 -s[=default} : Sequential reading of objects
38 -n : Object reading at NameTags
39 -a0...a3 : Tag List with PInPersist.AnalyseTags(0...3)
40 -lh : List PPersist handler classes
41 -lho : List PPersist handler and dataobj classes
[3028]42 -lmod : List initialized/registered modules
[1441]43
44 \endverbatim
45*/
46
[1306]47int main(int narg, char* arg[])
48{
49
50SambaInitiator smbinit;
[2636]51HiStatsInitiator hisinit;
[1306]52
53if ((narg < 2) || (strcmp(arg[1],"-h") == 0) ) {
[2658]54 cout << " Usage: scanppf [flags] filename \n"
[3028]55 << " flags = -s -n -a0 -a1 -a2 -a3 -lh -lho -lmod \n"
[2658]56 << " -s[=default} : Sequential reading of objects \n"
57 << " -n : Object reading at NameTags \n"
58 << " -a0...a3 : Tag List with PInPersist.AnalyseTags(0...3) \n"
59 << " -lh : List PPersist handler classes \n"
[3028]60 << " -lho : List PPersist handler and dataobj classes \n"
61 << " -lmod : List initialized/registered modules \n" << endl;
[2658]62 return(0);
[1306]63 }
64
65try {
[2658]66 string flnm;
[1306]67 bool seq=true;
68 bool ana=false;
69 int analev = 0;
70 string opt = "s";
[2658]71 if ((narg >= 2) && (*arg[1] == '-')) {
72 opt = arg[1];
73 if (narg > 2) flnm = arg[2];
74 }
75 else flnm = arg[1];
[1306]76
[2658]77 if (opt == "-lh") {
78 cout << " --- scanppf : List of registered handler classes --- " << endl;
79 PIOPersist::ListPPHandlers();
[1306]80 }
[2658]81 else if (opt == "-lho") {
82 cout << " --- scanppf : List of registered handler and DataObj classes --- " << endl;
83 PIOPersist::ListPPHandlers();
84 PIOPersist::ListDataObjClasses();
85 }
[3028]86 else if (opt == "-lmod") {
87 cout << " --- scanppf : List of registered module names and version --- " << endl;
88 SophyaInitiator::ListModules(cout);
89 }
[1306]90 else {
[2658]91 if (opt == "-n") seq = false;
[3425]92 else if ((opt[0] == '-') && (opt[1] == 'a')) {
93 ana = true;
94 analev = 0;
95 if (opt.length()>2) analev = opt[2]-'0';
96 }
[2658]97
98 if (ana) cout << " Analyse PInPersist( " << flnm << ") Level=" << analev << endl;
99 else {
100 if (!seq) cout << "PInPersist( " << flnm << ") Object Reading at NameTags " << endl;
101 else cout << "PInPersist( " << flnm << ") Sequential Object Reading " << endl;
102 }
103 PPersist* op = NULL;
104 cout << " Opening PPF file " << flnm << endl;
105 PInPersist s(flnm);
106
107 if (ana) s.AnalyseTags(analev); // Analysing all tags in file
108
109 else {
110 cout << " Version= " << s.Version() << " CreationDate= " << s.CreationDateStr() << endl;
111 int nt = s.NbNameTags();
112 cout << " Number of tags in file = " << nt << endl;
113 if ( seq || (nt < 1) ) {
114 while (1) {
115 op = s.ReadObject();
116 cout << " Object Type " << typeid(*op).name() << endl;
117 if (op) delete op;
118 }
119 }
120 for(int i=0; i<nt; i++) {
121 cout << ">>> TagNum= " << i << " TagName= " << s.GetTagName(i) << endl;
122 s.GotoNameTagNum(i);
[1306]123 op = s.ReadObject();
124 cout << " Object Type " << typeid(*op).name() << endl;
125 if (op) delete op;
126 }
127 }
128 }
129}
[1373]130catch (PThrowable & pex) {
131 cerr << " scanppf/Error - Exception catched " << (string)typeid(pex).name()
132 << " - Msg= " << pex.Msg() << endl;
[1306]133}
134
135cout << " ----------- End of scanppf ------------- " << endl;
136}
Note: See TracBrowser for help on using the repository browser.