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