#ifndef __WORKUNIT_H__
#define __WORKUNIT_H__

#include <iostream>
#include "mutualinformation.h"

/// work unit for a the cluster
/**
 * this should really be done with inheritance
 *
 * currently specifically for distributing levmar
 * alignment work
 */
class workunit
{
 public: 
  workunit();
  ~workunit();

  /// initialize the work for calculation
  int init( int transx, int transy, int slice, int parnum );

  /// get the data to be sent over to the worker
  /**
   * @param buf pointer to pointer where the data is going to be stored
   * @size size of the data
   *
   * will allocate memory to store the object
   */
  int pack( char **buf, int &size );

  /// unpack data
  int unpack( char *buf, int size );

  /// pack the results into a buffer
  int packresult( char **buf, int &size );

  /// sets the result
  int setresult( double bscore );

  /// gets the result
  int getresult( double &bscore );

  /// get the section that the work unit in assign for
  int getinput( int &transx, int &transy, int &slice, int &parnum );

 private:

  int mytransx;
  int mytransy;
  int myslice;
  int myparnum;

  /// score
  double score;

};

#endif
