| 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 | PIOPersist::Initialize() Starting Sophya Persistence management service | 
|---|
| 40 | SOPHYA Version  2.0 Revision 0 (V_Jul2006) -- Jul 17 2006 14:13:27 cxx | 
|---|
| 41 | Usage: scanppf [flags] filename | 
|---|
| 42 | flags = -s -n -a0 -a1 -a2 -a3 -lh -lho -lmod | 
|---|
| 43 | -s[=default} : Sequential reading of objects | 
|---|
| 44 | -n : Object reading at NameTags | 
|---|
| 45 | -a0...a3 : Tag List with PInPersist.AnalyseTags(0...3) | 
|---|
| 46 | -lh : List PPersist handler classes | 
|---|
| 47 | -lho : List PPersist handler and dataobj classes | 
|---|
| 48 | -lmod : List initialized/registered modules | 
|---|
| 49 |  | 
|---|
| 50 | \endverbatim | 
|---|
| 51 | */ | 
|---|
| 52 |  | 
|---|
| 53 | int main(int narg, char* arg[]) | 
|---|
| 54 | { | 
|---|
| 55 |  | 
|---|
| 56 | #ifdef __MWERKS__ | 
|---|
| 57 | narg = ccommand(&arg); | 
|---|
| 58 | #endif | 
|---|
| 59 |  | 
|---|
| 60 | SambaInitiator smbinit; | 
|---|
| 61 | HiStatsInitiator hisinit; | 
|---|
| 62 |  | 
|---|
| 63 | if ((narg < 2) || (strcmp(arg[1],"-h") == 0) ) { | 
|---|
| 64 | cout << " Usage: scanppf [flags] filename \n" | 
|---|
| 65 | << " flags = -s -n -a0 -a1 -a2 -a3 -lh -lho -lmod \n" | 
|---|
| 66 | << "   -s[=default} : Sequential reading of objects \n" | 
|---|
| 67 | << "   -n : Object reading at NameTags \n" | 
|---|
| 68 | << "   -a0...a3 : Tag List with PInPersist.AnalyseTags(0...3) \n" | 
|---|
| 69 | << "   -lh : List PPersist handler classes \n" | 
|---|
| 70 | << "   -lho : List PPersist handler and dataobj classes \n" | 
|---|
| 71 | << "   -lmod : List initialized/registered modules \n" << endl; | 
|---|
| 72 | return(0); | 
|---|
| 73 | } | 
|---|
| 74 |  | 
|---|
| 75 | try { | 
|---|
| 76 | string flnm; | 
|---|
| 77 | bool seq=true; | 
|---|
| 78 | bool ana=false; | 
|---|
| 79 | int analev = 0; | 
|---|
| 80 | string opt = "s"; | 
|---|
| 81 | if ((narg >= 2) && (*arg[1] == '-')) { | 
|---|
| 82 | opt = arg[1]; | 
|---|
| 83 | if (narg > 2) flnm = arg[2]; | 
|---|
| 84 | } | 
|---|
| 85 | else flnm = arg[1]; | 
|---|
| 86 |  | 
|---|
| 87 | if (opt == "-lh")  { | 
|---|
| 88 | cout << " --- scanppf : List of registered handler classes --- " << endl; | 
|---|
| 89 | PIOPersist::ListPPHandlers(); | 
|---|
| 90 | } | 
|---|
| 91 | else if (opt == "-lho") { | 
|---|
| 92 | cout << " --- scanppf : List of registered handler and DataObj classes --- " << endl; | 
|---|
| 93 | PIOPersist::ListPPHandlers(); | 
|---|
| 94 | PIOPersist::ListDataObjClasses(); | 
|---|
| 95 | } | 
|---|
| 96 | else if (opt == "-lmod") { | 
|---|
| 97 | cout << " --- scanppf : List of registered module names and version --- " << endl; | 
|---|
| 98 | SophyaInitiator::ListModules(cout); | 
|---|
| 99 | } | 
|---|
| 100 | else { | 
|---|
| 101 | if (opt == "-n")  seq = false; | 
|---|
| 102 | else if (opt[1] == 'a') {  ana = true;  analev = opt[1]-'0'; } | 
|---|
| 103 |  | 
|---|
| 104 | if (ana)   cout << " Analyse PInPersist( " << flnm << ")  Level=" << analev << endl; | 
|---|
| 105 | else { | 
|---|
| 106 | if (!seq) cout << "PInPersist( " << flnm << ") Object Reading at NameTags " << endl; | 
|---|
| 107 | else  cout << "PInPersist( " << flnm << ") Sequential Object Reading " << endl; | 
|---|
| 108 | } | 
|---|
| 109 | PPersist* op = NULL; | 
|---|
| 110 | cout << " Opening PPF file " << flnm << endl; | 
|---|
| 111 | PInPersist s(flnm); | 
|---|
| 112 |  | 
|---|
| 113 | if (ana) s.AnalyseTags(analev);   // Analysing all tags in file | 
|---|
| 114 |  | 
|---|
| 115 | else { | 
|---|
| 116 | cout << " Version= " << s.Version() << " CreationDate= " << s.CreationDateStr() << endl; | 
|---|
| 117 | int nt = s.NbNameTags(); | 
|---|
| 118 | cout << " Number of tags in file = " << nt << endl; | 
|---|
| 119 | if ( seq || (nt < 1) ) { | 
|---|
| 120 | while (1) { | 
|---|
| 121 | op = s.ReadObject(); | 
|---|
| 122 | cout << " Object Type " << typeid(*op).name() << endl; | 
|---|
| 123 | if (op) delete op; | 
|---|
| 124 | } | 
|---|
| 125 | } | 
|---|
| 126 | for(int i=0; i<nt; i++) { | 
|---|
| 127 | cout << ">>> TagNum= " << i << " TagName= " << s.GetTagName(i) << endl; | 
|---|
| 128 | s.GotoNameTagNum(i); | 
|---|
| 129 | op = s.ReadObject(); | 
|---|
| 130 | cout << " Object Type " << typeid(*op).name() << endl; | 
|---|
| 131 | if (op) delete op; | 
|---|
| 132 | } | 
|---|
| 133 | } | 
|---|
| 134 | } | 
|---|
| 135 | } | 
|---|
| 136 | catch (PThrowable & pex) { | 
|---|
| 137 | cerr << " scanppf/Error - Exception catched " << (string)typeid(pex).name() | 
|---|
| 138 | << " - Msg= " << pex.Msg() << endl; | 
|---|
| 139 | } | 
|---|
| 140 |  | 
|---|
| 141 | cout << " ----------- End of scanppf ------------- " << endl; | 
|---|
| 142 | } | 
|---|