source: Sophya/trunk/SophyaProg/PrgUtil/scanppf.cc@ 3028

Last change on this file since 3028 was 3028, checked in by ansari, 19 years ago

Ajout flag -lmod ds scanppf.cc - Reza 17/7/2006

File size: 4.2 KB
RevLine 
[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
[3028]40SOPHYA Version 2.0 Revision 0 (V_Jul2006) -- Jul 17 2006 14:13:27 cxx
[2662]41 Usage: scanppf [flags] filename
[3028]42 flags = -s -n -a0 -a1 -a2 -a3 -lh -lho -lmod
[2662]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
[3028]48 -lmod : List initialized/registered modules
[1441]49
50 \endverbatim
51*/
52
[1306]53int main(int narg, char* arg[])
54{
55
56#ifdef __MWERKS__
57narg = ccommand(&arg);
58#endif
59
60SambaInitiator smbinit;
[2636]61HiStatsInitiator hisinit;
[1306]62
63if ((narg < 2) || (strcmp(arg[1],"-h") == 0) ) {
[2658]64 cout << " Usage: scanppf [flags] filename \n"
[3028]65 << " flags = -s -n -a0 -a1 -a2 -a3 -lh -lho -lmod \n"
[2658]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"
[3028]70 << " -lho : List PPersist handler and dataobj classes \n"
71 << " -lmod : List initialized/registered modules \n" << endl;
[2658]72 return(0);
[1306]73 }
74
75try {
[2658]76 string flnm;
[1306]77 bool seq=true;
78 bool ana=false;
79 int analev = 0;
80 string opt = "s";
[2658]81 if ((narg >= 2) && (*arg[1] == '-')) {
82 opt = arg[1];
83 if (narg > 2) flnm = arg[2];
84 }
85 else flnm = arg[1];
[1306]86
[2658]87 if (opt == "-lh") {
88 cout << " --- scanppf : List of registered handler classes --- " << endl;
89 PIOPersist::ListPPHandlers();
[1306]90 }
[2658]91 else if (opt == "-lho") {
92 cout << " --- scanppf : List of registered handler and DataObj classes --- " << endl;
93 PIOPersist::ListPPHandlers();
94 PIOPersist::ListDataObjClasses();
95 }
[3028]96 else if (opt == "-lmod") {
97 cout << " --- scanppf : List of registered module names and version --- " << endl;
98 SophyaInitiator::ListModules(cout);
99 }
[1306]100 else {
[2658]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);
[1306]129 op = s.ReadObject();
130 cout << " Object Type " << typeid(*op).name() << endl;
131 if (op) delete op;
132 }
133 }
134 }
135}
[1373]136catch (PThrowable & pex) {
137 cerr << " scanppf/Error - Exception catched " << (string)typeid(pex).name()
138 << " - Msg= " << pex.Msg() << endl;
[1306]139}
140
141cout << " ----------- End of scanppf ------------- " << endl;
142}
Note: See TracBrowser for help on using the repository browser.