1 | #include <stdio.h>
|
---|
2 | #include <stdlib.h>
|
---|
3 | #include <string.h>
|
---|
4 | #include <typeinfo>
|
---|
5 | #include <iostream>
|
---|
6 | #include <string>
|
---|
7 |
|
---|
8 | #include "sopnamsp.h"
|
---|
9 | #include "ppersist.h"
|
---|
10 | #include "anydataobj.h"
|
---|
11 | #include "sambainit.h"
|
---|
12 | #include "histinit.h"
|
---|
13 |
|
---|
14 |
|
---|
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
|
---|
33 | PIOPersist::Initialize() Starting Sophya Persistence management service
|
---|
34 | SOPHYA Version 2.0 Revision 0 (V_Jul2006) -- Jul 17 2006 14:13:27 cxx
|
---|
35 | Usage: scanppf [flags] filename
|
---|
36 | flags = -s -n -a0 -a1 -a2 -a3 -lh -lho -lmod
|
---|
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
|
---|
42 | -lmod : List initialized/registered modules
|
---|
43 |
|
---|
44 | \endverbatim
|
---|
45 | */
|
---|
46 |
|
---|
47 | int main(int narg, char* arg[])
|
---|
48 | {
|
---|
49 |
|
---|
50 | SambaInitiator smbinit;
|
---|
51 | HiStatsInitiator hisinit;
|
---|
52 |
|
---|
53 | if ((narg < 2) || (strcmp(arg[1],"-h") == 0) ) {
|
---|
54 | cout << " Usage: scanppf [flags] filename \n"
|
---|
55 | << " flags = -s -n -a0 -a1 -a2 -a3 -lh -lho -lmod \n"
|
---|
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"
|
---|
60 | << " -lho : List PPersist handler and dataobj classes \n"
|
---|
61 | << " -lmod : List initialized/registered modules \n" << endl;
|
---|
62 | return(0);
|
---|
63 | }
|
---|
64 |
|
---|
65 | try {
|
---|
66 | string flnm;
|
---|
67 | bool seq=true;
|
---|
68 | bool ana=false;
|
---|
69 | int analev = 0;
|
---|
70 | string opt = "s";
|
---|
71 | if ((narg >= 2) && (*arg[1] == '-')) {
|
---|
72 | opt = arg[1];
|
---|
73 | if (narg > 2) flnm = arg[2];
|
---|
74 | }
|
---|
75 | else flnm = arg[1];
|
---|
76 |
|
---|
77 | if (opt == "-lh") {
|
---|
78 | cout << " --- scanppf : List of registered handler classes --- " << endl;
|
---|
79 | PIOPersist::ListPPHandlers();
|
---|
80 | }
|
---|
81 | else if (opt == "-lho") {
|
---|
82 | cout << " --- scanppf : List of registered handler and DataObj classes --- " << endl;
|
---|
83 | PIOPersist::ListPPHandlers();
|
---|
84 | PIOPersist::ListDataObjClasses();
|
---|
85 | }
|
---|
86 | else if (opt == "-lmod") {
|
---|
87 | cout << " --- scanppf : List of registered module names and version --- " << endl;
|
---|
88 | SophyaInitiator::ListModules(cout);
|
---|
89 | }
|
---|
90 | else {
|
---|
91 | if (opt == "-n") seq = false;
|
---|
92 | else if ((opt[0] == '-') && (opt[1] == 'a')) {
|
---|
93 | ana = true;
|
---|
94 | analev = 0;
|
---|
95 | if (opt.length()>2) analev = opt[2]-'0';
|
---|
96 | }
|
---|
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);
|
---|
123 | op = s.ReadObject();
|
---|
124 | cout << " Object Type " << typeid(*op).name() << endl;
|
---|
125 | if (op) delete op;
|
---|
126 | }
|
---|
127 | }
|
---|
128 | }
|
---|
129 | }
|
---|
130 | catch (PThrowable & pex) {
|
---|
131 | cerr << " scanppf/Error - Exception catched " << (string)typeid(pex).name()
|
---|
132 | << " - Msg= " << pex.Msg() << endl;
|
---|
133 | }
|
---|
134 |
|
---|
135 | cout << " ----------- End of scanppf ------------- " << endl;
|
---|
136 | }
|
---|