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