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 | <LI> prjsmap : Molleweide and sinus projection of sky maps (prjsmap.cc)
|
---|
26 | <LI> map2cl : Computes power spectra (C(l)) on spherical maps (map2cl.cc)
|
---|
27 | <LI> cl2map : generates spherical maps from power spectra (C(l)) (cl2map.cc)
|
---|
28 | </UL>
|
---|
29 | */
|
---|
30 |
|
---|
31 | /*!
|
---|
32 | \ingroup PrgUtil
|
---|
33 | \file scanppf.cc
|
---|
34 | \brief \b scanppf: Check and scan PPF files
|
---|
35 |
|
---|
36 | \verbatim
|
---|
37 |
|
---|
38 | csh> scanppf -h
|
---|
39 | SOPHYA Version 1.1 Revision 0 (V_Fev2001) -- Mar 9 2001 15:45:31 cxx
|
---|
40 | Usage: scanppf filename [s/n/a0/a1/a2/a3]
|
---|
41 | s[=default} : Sequential reading of objects
|
---|
42 | n : Object reading at NameTags
|
---|
43 | a0...a3 : Tag List with PInPersist.AnalyseTags(0...3)
|
---|
44 |
|
---|
45 | \endverbatim
|
---|
46 | */
|
---|
47 |
|
---|
48 | int main(int narg, char* arg[])
|
---|
49 | {
|
---|
50 |
|
---|
51 | #ifdef __MWERKS__
|
---|
52 | narg = ccommand(&arg);
|
---|
53 | #endif
|
---|
54 |
|
---|
55 | SambaInitiator smbinit;
|
---|
56 | HiStatsInitiator hisinit;
|
---|
57 |
|
---|
58 | if ((narg < 2) || (strcmp(arg[1],"-h") == 0) ) {
|
---|
59 | cout << " Usage: scanppf [flags] filename \n"
|
---|
60 | << " flags = -s -n -a0 -a1 -a2 -a3 -lh -lho \n"
|
---|
61 | << " -s[=default} : Sequential reading of objects \n"
|
---|
62 | << " -n : Object reading at NameTags \n"
|
---|
63 | << " -a0...a3 : Tag List with PInPersist.AnalyseTags(0...3) \n"
|
---|
64 | << " -lh : List PPersist handler classes \n"
|
---|
65 | << " -lho : List PPersist handler and dataobj classes \n" << endl;
|
---|
66 | return(0);
|
---|
67 | }
|
---|
68 |
|
---|
69 | try {
|
---|
70 | string flnm;
|
---|
71 | bool seq=true;
|
---|
72 | bool ana=false;
|
---|
73 | int analev = 0;
|
---|
74 | string opt = "s";
|
---|
75 | if ((narg >= 2) && (*arg[1] == '-')) {
|
---|
76 | opt = arg[1];
|
---|
77 | if (narg > 2) flnm = arg[2];
|
---|
78 | }
|
---|
79 | else flnm = arg[1];
|
---|
80 |
|
---|
81 | if (opt == "-lh") {
|
---|
82 | cout << " --- scanppf : List of registered handler classes --- " << endl;
|
---|
83 | PIOPersist::ListPPHandlers();
|
---|
84 | }
|
---|
85 | else if (opt == "-lho") {
|
---|
86 | cout << " --- scanppf : List of registered handler and DataObj classes --- " << endl;
|
---|
87 | PIOPersist::ListPPHandlers();
|
---|
88 | PIOPersist::ListDataObjClasses();
|
---|
89 | }
|
---|
90 | else {
|
---|
91 | if (opt == "-n") seq = false;
|
---|
92 | else if (opt[1] == 'a') { ana = true; analev = opt[1]-'0'; }
|
---|
93 |
|
---|
94 | if (ana) cout << " Analyse PInPersist( " << flnm << ") Level=" << analev << endl;
|
---|
95 | else {
|
---|
96 | if (!seq) cout << "PInPersist( " << flnm << ") Object Reading at NameTags " << endl;
|
---|
97 | else cout << "PInPersist( " << flnm << ") Sequential Object Reading " << endl;
|
---|
98 | }
|
---|
99 | PPersist* op = NULL;
|
---|
100 | cout << " Opening PPF file " << flnm << endl;
|
---|
101 | PInPersist s(flnm);
|
---|
102 |
|
---|
103 | if (ana) s.AnalyseTags(analev); // Analysing all tags in file
|
---|
104 |
|
---|
105 | else {
|
---|
106 | cout << " Version= " << s.Version() << " CreationDate= " << s.CreationDateStr() << endl;
|
---|
107 | int nt = s.NbNameTags();
|
---|
108 | cout << " Number of tags in file = " << nt << endl;
|
---|
109 | if ( seq || (nt < 1) ) {
|
---|
110 | while (1) {
|
---|
111 | op = s.ReadObject();
|
---|
112 | cout << " Object Type " << typeid(*op).name() << endl;
|
---|
113 | if (op) delete op;
|
---|
114 | }
|
---|
115 | }
|
---|
116 | for(int i=0; i<nt; i++) {
|
---|
117 | cout << ">>> TagNum= " << i << " TagName= " << s.GetTagName(i) << endl;
|
---|
118 | s.GotoNameTagNum(i);
|
---|
119 | op = s.ReadObject();
|
---|
120 | cout << " Object Type " << typeid(*op).name() << endl;
|
---|
121 | if (op) delete op;
|
---|
122 | }
|
---|
123 | }
|
---|
124 | }
|
---|
125 | }
|
---|
126 | catch (PThrowable & pex) {
|
---|
127 | cerr << " scanppf/Error - Exception catched " << (string)typeid(pex).name()
|
---|
128 | << " - Msg= " << pex.Msg() << endl;
|
---|
129 | }
|
---|
130 |
|
---|
131 | cout << " ----------- End of scanppf ------------- " << endl;
|
---|
132 | }
|
---|