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

Last change on this file since 3507 was 3425, checked in by ansari, 18 years ago

Correction decodage argument -a0 -a1 ... ds scanppf.cc - Reza 08/12/2007

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