Print

Print


Commit in lcio/src/cpp/src/EXAMPLE on random_access_io_branch
addRandomAccess.cc+50added 1.1.2.1
simple program for appending direct access records to existing old files

lcio/src/cpp/src/EXAMPLE
addRandomAccess.cc added at 1.1.2.1
diff -N addRandomAccess.cc
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ addRandomAccess.cc	1 May 2010 11:13:26 -0000	1.1.2.1
@@ -0,0 +1,50 @@
+#include "lcio.h"
+
+#include "IO/LCWriter.h"
+//#include "EVENT/LCIO.h"
+
+#include <iostream>
+#include <sstream>
+
+using namespace lcio ;
+
+static std::vector<std::string> FILEN ; 
+
+
+/** Simple program that opens existing LCIO files and appends the records needed for direct access - if they don't exist.
+ */
+
+int main(int argc, char** argv ){
+  
+    
+    // create sio writer
+    LCWriter* lcWrt = LCFactory::getInstance()->createLCWriter()  ;
+
+    // read file names from command line (only argument) 
+    if( argc < 2) {
+      std::cout << " usage:  addRandomAccess <input-file1> [[input-file2],...]" << std::endl ;
+      exit(1) ;
+    }
+    for(int i=1 ; i < argc ; i++){
+      FILEN.push_back( argv[i] )  ;
+    }
+
+    int nFiles = argc-1 ;
+
+    for( int i=0 ; i <nFiles ; ++i ) {
+
+      try{
+      
+	lcWrt->open( FILEN[i] , LCIO::WRITE_APPEND )  ;
+
+	lcWrt->close() ;
+
+      }catch(IOException& e){
+
+	std::cout << " io error in file  " << FILEN[i] << " : " << e.what() << std::endl ;
+      }
+    }
+
+    return 0 ;
+}
+
CVSspam 0.2.8