[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 | #ifdef __MWERKS__
|
---|
| 14 | #include <console.h>
|
---|
| 15 | #endif
|
---|
| 16 |
|
---|
[1441] | 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
|
---|
[2662] | 39 | PIOPersist::Initialize() Starting Sophya Persistence management service
|
---|
| 40 | SOPHYA Version 1.8 Revision 40 (V_Avr2005) -- Apr 7 2005 12:00:24 cxx
|
---|
| 41 | Usage: scanppf [flags] filename
|
---|
| 42 | flags = -s -n -a0 -a1 -a2 -a3 -lh -lho
|
---|
| 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
|
---|
[1441] | 48 |
|
---|
| 49 | \endverbatim
|
---|
| 50 | */
|
---|
| 51 |
|
---|
[1306] | 52 | int main(int narg, char* arg[])
|
---|
| 53 | {
|
---|
| 54 |
|
---|
| 55 | #ifdef __MWERKS__
|
---|
| 56 | narg = ccommand(&arg);
|
---|
| 57 | #endif
|
---|
| 58 |
|
---|
| 59 | SambaInitiator smbinit;
|
---|
[2636] | 60 | HiStatsInitiator hisinit;
|
---|
[1306] | 61 |
|
---|
| 62 | if ((narg < 2) || (strcmp(arg[1],"-h") == 0) ) {
|
---|
[2658] | 63 | cout << " Usage: scanppf [flags] filename \n"
|
---|
| 64 | << " flags = -s -n -a0 -a1 -a2 -a3 -lh -lho \n"
|
---|
| 65 | << " -s[=default} : Sequential reading of objects \n"
|
---|
| 66 | << " -n : Object reading at NameTags \n"
|
---|
| 67 | << " -a0...a3 : Tag List with PInPersist.AnalyseTags(0...3) \n"
|
---|
| 68 | << " -lh : List PPersist handler classes \n"
|
---|
| 69 | << " -lho : List PPersist handler and dataobj classes \n" << endl;
|
---|
| 70 | return(0);
|
---|
[1306] | 71 | }
|
---|
| 72 |
|
---|
| 73 | try {
|
---|
[2658] | 74 | string flnm;
|
---|
[1306] | 75 | bool seq=true;
|
---|
| 76 | bool ana=false;
|
---|
| 77 | int analev = 0;
|
---|
| 78 | string opt = "s";
|
---|
[2658] | 79 | if ((narg >= 2) && (*arg[1] == '-')) {
|
---|
| 80 | opt = arg[1];
|
---|
| 81 | if (narg > 2) flnm = arg[2];
|
---|
| 82 | }
|
---|
| 83 | else flnm = arg[1];
|
---|
[1306] | 84 |
|
---|
[2658] | 85 | if (opt == "-lh") {
|
---|
| 86 | cout << " --- scanppf : List of registered handler classes --- " << endl;
|
---|
| 87 | PIOPersist::ListPPHandlers();
|
---|
[1306] | 88 | }
|
---|
[2658] | 89 | else if (opt == "-lho") {
|
---|
| 90 | cout << " --- scanppf : List of registered handler and DataObj classes --- " << endl;
|
---|
| 91 | PIOPersist::ListPPHandlers();
|
---|
| 92 | PIOPersist::ListDataObjClasses();
|
---|
| 93 | }
|
---|
[1306] | 94 | else {
|
---|
[2658] | 95 | if (opt == "-n") seq = false;
|
---|
| 96 | else if (opt[1] == 'a') { ana = true; analev = opt[1]-'0'; }
|
---|
| 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);
|
---|
[1306] | 123 | op = s.ReadObject();
|
---|
| 124 | cout << " Object Type " << typeid(*op).name() << endl;
|
---|
| 125 | if (op) delete op;
|
---|
| 126 | }
|
---|
| 127 | }
|
---|
| 128 | }
|
---|
| 129 | }
|
---|
[1373] | 130 | catch (PThrowable & pex) {
|
---|
| 131 | cerr << " scanppf/Error - Exception catched " << (string)typeid(pex).name()
|
---|
| 132 | << " - Msg= " << pex.Msg() << endl;
|
---|
[1306] | 133 | }
|
---|
| 134 |
|
---|
| 135 | cout << " ----------- End of scanppf ------------- " << endl;
|
---|
| 136 | }
|
---|