Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members

DecoderOutputTester.cpp

Go to the documentation of this file.
00001 
00006 #include "common/log.h"
00007 #include "test/io/codec/decoder/DecoderOutputTester.hpp"
00008 
00009 #include "io/output/normal/BufferedNormalOutput.hpp"
00010 #include "io/codec/decoder/normal/SimpleNormalDecoder.hpp"
00011 #include "io/codec/decoder/normal/CacheNormalDecoder.hpp"
00012 #include "io/codec/decoder/df/CacheDFDecoder.hpp"
00013 #include "io/codec/decoder/df/SimpleBufferedDFDecoder.hpp"
00014 
00015 #include <ctime>
00016 #include <iostream>
00017 
00018 
00019  void DecoderOutputTester::usageDecoderOutput()
00020 {
00021    std::cerr << "\nUsage: decoder_output_test type writer set_size output_file [random_seed]\n ";
00022    std::cerr << " type\t {normal, df}"<<std::endl;   
00023    std::cerr << " If type = normal, then:"<<std::endl;   
00024    std::cerr << " writer\t {simple, cache}"<<std::endl;  
00025    std::cerr << " If type = df, then:"<<std::endl;    
00026    std::cerr << " writer\t {buffered, cache}"<<std::endl;   
00027 }
00028 
00029 int DecoderOutputTester::doTest(
00030    int argc, char *argv[] )
00031 {
00032    if ( argc < 5 )
00033    {
00034       usageDecoderOutput();
00035       return 3;
00036    }
00037    else
00038    {
00039       unsigned int set_size = atoi(argv[3]);
00040       int rand_seed;
00041       log_info(0,"The size of the itemset is set to %d.", set_size);
00042       if(argc < 6)
00043          rand_seed = static_cast<int>(time(0));
00044       else
00045          rand_seed = atoi(argv[5]);
00046       log_info(0,"The random seed is set to %d.", rand_seed);
00047       srand(rand_seed);
00048 
00049       if( strcmp(argv[1],"normal") == 0 )
00050       {
00051          if(strcmp(argv[2],"simple") == 0)
00052          {
00053             log_info(0,"Simple normal decoder is selected");
00054             writeAllCodedSubsetsNormal< SimpleNormalDecoder< > >( 
00055                set_size, argv[4] );
00056          }
00057          else if(strcmp(argv[2],"cache") == 0)
00058          {
00059             log_info(0,"Cache normal decoder is selected");
00060             writeAllCodedSubsetsNormal< CacheNormalDecoder< > >( 
00061                set_size, argv[4] );
00062          } 
00063          else
00064          {
00065             usageDecoderOutput();
00066             log_err(0,"Unknown writer: %s", argv[2]);
00067             return 2;
00068          }
00069       }
00070       else if(strcmp(argv[1],"df") == 0)
00071       {
00072          if(strcmp(argv[2],"buffered") == 0)
00073          {
00074             log_info(0,"Buffered dfo decoder is selected");
00075             writeAllCodedSubsetsDF< SimpleBufferedDFDecoder< > >( 
00076                set_size, argv[4] );
00077          }
00078          else if(strcmp(argv[2],"cache") == 0)
00079          {
00080             log_info(0,"Cache DF decoder is selected");
00081             writeAllCodedSubsetsDF< CacheDFDecoder< > >( 
00082                set_size, argv[4] );
00083          }
00084          else
00085          {
00086             usageDecoderOutput();
00087             log_err(0,"Unknown writer: %s", argv[2]);
00088             return 2;
00089          }
00090       }
00091       else
00092       {
00093          usageDecoderOutput();
00094          log_err(0,"Unknown type: %s", argv[1]);
00095          return 1;
00096       }
00097    }
00098    return 0;
00099 }
00100 

Generated on Sun Sep 17 17:50:38 2006 for FIM environment by  doxygen 1.4.4