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

SimpleOutputTester.hpp

Go to the documentation of this file.
00001 
00014 #ifndef SimpleOutputTester_HPP
00015 #define SimpleOutputTester_HPP
00016 
00017 #include "io/FileReprBase.hpp"
00018 #include "common.hpp"
00019 #include "common/log.h"
00020 #include <vector>
00021 
00022 
00023 class SimpleOutputTester
00024 {
00025    public:
00026       void usageSimpleOutput();
00027       void doTest( int argc, char *argv[] )
00028          throw(std::ios_base::failure);
00029    private:
00030       template <class O_M> void makeBufferedWriter( 
00031          char* file_name, const std::streamsize lowlevel_buffer_size,
00032          const std::streamsize highlevel_buffer_size, const unsigned int set_size,
00033          const int rand_seed) throw(std::ios_base::failure);
00034 
00036       template <class O_M> void writeAllSubsets( 
00037          O_M& o_manager, const unsigned int set_size,
00038          const int rand_seed );
00039          
00040 };
00041 
00042 template <class O_M> void SimpleOutputTester::
00043 makeBufferedWriter( 
00044    char* file_name, const std::streamsize lowlevel_buffer_size,
00045    const std::streamsize highlevel_buffer_size, const unsigned int set_size,
00046    const int rand_seed) throw(std::ios_base::failure)
00047 {
00048    typename O_M::params_t par;
00049    par.file_name = file_name;
00050    par.mode = FileReprBase::WRITE;
00051    par.file_buffer_size = lowlevel_buffer_size;
00052    par.buffer_size = highlevel_buffer_size;
00053    O_M o_manager(&par);
00054    writeAllSubsets( o_manager, set_size,
00055                        rand_seed );
00056 }
00062 template <class O_M> void SimpleOutputTester::
00063 writeAllSubsets( O_M& o_manager, const unsigned int set_size,
00064                  const int rand_seed )
00065 {
00066    std::vector<item_t> itemset(set_size);
00067    std::vector<item_t> subset;
00068    std::vector<bool> pattern(set_size, false);
00069    std::vector<bool>::size_type index;
00070 
00071    log_info(0,"Generating random items...");
00072    for( unsigned int index=0; index < set_size; ++index )
00073       itemset[index] = rand();
00074 
00075    counter_t support = 1; //we dont care about the support
00076    log_info(0,"Generating and writting out the subsets...");
00077    do
00078    {
00079       o_manager.writeItemsetAndCounter( 
00080          subset.begin(), subset.end(), support);
00081       index=0;
00082       while(index < set_size && pattern[index] == true )
00083       {
00084          pattern[index] = false;
00085          subset.pop_back();
00086          index++;
00087       }
00088       if( index == set_size )
00089          break;
00090       else
00091       {
00092          pattern[index] = true;
00093          subset.push_back(itemset[index]);
00094       }
00095    }
00096    while(true);
00097 }
00098 
00099 #endif

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