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