// file: $isip/doc/examples/class/mmedia/mmedia_example_10/example.cc
//

// isip include files
//
#include <Splitter.h>
#include <Console.h>
#include <Filename.h>

// this example demonstrates how to use the Splitter object
//
int main(int argc, const char** argv) {

  // declare Splitter objects
  //
  // declare the splitter object
  //
  Filename params_file(L"parameter_file.sof");
  Filename identifier_list(L"identifiers.sof");
  Filename machine_list(L"machine_list.sof");
  Filename accumulator_list(L"accumulator_list.sof");
  Filename database_file(L"machine_database.sof");
  
  Splitter split_00;

  // set the splitter mode
  //
  split_00.setSplitMode(Splitter::SPEED);

  // set the parameter file for the splitter object
  //
  split_00.setParamFile(params_file);

  // set the identifier list for the splitter object
  //  
  split_00.setIdentifierList(identifier_list);

  // set the machine list for the splitter object
  //    
  split_00.setMachineList(machine_list);

  // set the accumulator list for the splitter object
  //
  split_00.setAccumulatorList(accumulator_list);

  // load the machine database
  //
  if (!database_file.eq(String::EMPTY)) {
    
    Sof tmp_sof;
    MachineDatabase& mdb = split_00.getMachineDatabase();
    
    if (tmp_sof.open(database_file)) {
      mdb.read(tmp_sof, (long)0);
    }
    
    tmp_sof.close();
  }
    
  // distribute the jobs in parallel on the machines
  //
  split_00.run();
  
  // exit gracefully
  //
  Integral::exit();
}
