allocate_seq_no.cxx

Go to the documentation of this file.
00001 #include <TSK_DBI_Log.hxx>
00002 #include "TSeqNoAllocator.hxx"
00003 #include "Rtypes.h"
00004 
00005 #include <cstdlib>
00006 #include <iostream>
00007 #include <string>
00008 
00009 // Standalone utility to issue local and global SEQNOs.
00010 
00011 // Invocation: seqno=`allocate_seq_no.exe <table-name> { <requireGlobal> <dbNo> } | tail -1`
00012 
00013 // Where:-
00014 //   tableName       in    The table for which the SEQNO is required.
00015 //   requireGlobal   in    The type of SEQNO required:-
00016 //                           > 0  Must be global
00017 //                           = 0  Must be global if supplied dbNo is authorising
00018 //                                and table isn't temporary otherwise local
00019 //                           < 0  Must be local
00020 //   dbNo            in     The entry in the cascade for which the SEQNO is required
00021 //
00022 //   seqno           out    The allocated SEQNO (or 0 if unable to allocate one)
00023 //
00024 //   | tail -1       Is need to filter the output and keep only the last line.
00025 
00026 
00027 int main(int argc, char **argv) {
00028 
00029   if ( argc < 2 ) {
00030     SK_DBI_Error("ERROR: Insufficient arguments passed to allocate_seq_no.exe.");
00031     std::cout << "0" << std::endl;
00032    return 1;
00033   }
00034   std::string table_name(argv[1]);
00035   Int_t requireGlobal = 0;
00036   Int_t dbNo          = 0;
00037   if ( argc > 2 ) requireGlobal = atoi(argv[2]);
00038   if ( argc > 3 ) dbNo          = atoi(argv[3]);
00039   TSeqNoAllocator sna = TSeqNoAllocator();
00040   Int_t seqno = sna.GetSeqNo(table_name,requireGlobal,dbNo);
00041   std::cout << seqno << std::endl;
00042   return 0;
00043 }

Generated on 11 Aug 2013 for SKDatabase by  doxygen 1.6.1