assembler_c Class Reference

The assembler. More...

#include <assembler.h>

Inheritance diagram for assembler_c:

Inheritance graph
[legend]

List of all members.

Public Types

enum  errState {
  ERR_NONE, ERR_TOO_MANY_UNITS, ERR_TOO_FEW_UNITS, ERR_CAN_NOT_PLACE,
  ERR_CAN_NOT_RESTORE_VERSION, ERR_CAN_NOT_RESTORE_SYNTAX, ERR_PUZZLE_UNHANDABLE
}
 the possible error conditions that can be found while preparing the puzzle More...

Public Member Functions

 assembler_c (void)
 initialisation, only the things that can be done quickly are done here
virtual ~assembler_c (void)
virtual errState createMatrix (const problem_c *, bool, bool, bool)
 the part of the initialisation that may take a while.
virtual int getErrorsParam (void)
 when createMatrix returns an error you can call this function to find out which piece is involved, or other additional information
virtual void reduce (void)
 Try to optimize piece placement.
virtual unsigned int getReducePiece (void) const
 Then running in an extra thread it is possible to find out which piece is worked on by reduce.
virtual void assemble (assembler_cb *)
 start the assembly process.
virtual unsigned long getIterations (void)
 this function returns a number reflecting the complexity of the puzzle.
virtual float getFinished (void) const
 a function that returns the finished percentage in the range between 0 and 1.
virtual void stop (void)
 stops the assembly process sometimes in the near future.
virtual bool stopped (void) const
 returns true, as soon as the process really has stopped
virtual errState setPosition (const char *string, const char *version)
 sets the position of the assembly process, so that it continues exactly where it stood, when getPosition was called
virtual void save (xmlWriter_c &xml) const
 this function saves the current state of the assembler into an xml node to write it to an file.
virtual bool getPiecePlacementSupported (void) const
virtual unsigned int getPiecePlacementCount (unsigned int) const
virtual unsigned int getPiecePlacement (unsigned int, int, unsigned int, unsigned char *, int *, int *, int *) const
virtual void debug_step (unsigned long)
virtual assembly_cgetAssembly (void)=0

Private Member Functions

 assembler_c (const assembler_c &)
void operator= (const assembler_c &)


Detailed Description

The assembler.

As the assembly could be done using different routines we provide an general interface to the assemblers using this abstract base class.

But all must provide the same interface: as describes here. All must use the callback for each found assembly.


Member Enumeration Documentation

the possible error conditions that can be found while preparing the puzzle

Enumerator:
ERR_NONE  no error
ERR_TOO_MANY_UNITS  pieces contain too many units
ERR_TOO_FEW_UNITS  pieces contain too few units
ERR_CAN_NOT_PLACE  one piece has not placement
ERR_CAN_NOT_RESTORE_VERSION  happens on restore, when the versions of the saved information mismatches
ERR_CAN_NOT_RESTORE_SYNTAX  happens on restore, when the information seems wrong
ERR_PUZZLE_UNHANDABLE  the puzzle contains definitions that can not be (like ranges, multipieces, ...)


Constructor & Destructor Documentation

assembler_c::assembler_c ( void   )  [inline]

initialisation, only the things that can be done quickly are done here

virtual assembler_c::~assembler_c ( void   )  [inline, virtual]

assembler_c::assembler_c ( const assembler_c  )  [private]


Member Function Documentation

virtual void assembler_c::assemble ( assembler_cb  )  [inline, virtual]

start the assembly process.

it is intended that the assembly process runs in a different thread from the controlling thread. When this is the case the controlling thread can call stop to make the assembly thread stop working. It will then return from this function but can be resumed any time

Reimplemented in assembler_0_c, and assembler_1_c.

Referenced by solveThread_c::run().

assembler_c::errState assembler_c::createMatrix ( const problem_c ,
bool  ,
bool  ,
bool   
) [virtual]

the part of the initialisation that may take a while.

when keep mirror is true, the assembler must not throw away mirror solutions but it still removes solutions that are rotations.

Reimplemented in assembler_0_c, and assembler_1_c.

References ERR_NONE.

Referenced by solveThread_c::run().

virtual void assembler_c::debug_step ( unsigned long   )  [inline, virtual]

Reimplemented in assembler_0_c, and assembler_1_c.

virtual assembly_c* assembler_c::getAssembly ( void   )  [pure virtual]

Implemented in assembler_0_c, and assembler_1_c.

virtual int assembler_c::getErrorsParam ( void   )  [inline, virtual]

when createMatrix returns an error you can call this function to find out which piece is involved, or other additional information

Reimplemented in assembler_0_c, and assembler_1_c.

Referenced by solveThread_c::run().

virtual float assembler_c::getFinished ( void   )  const [inline, virtual]

a function that returns the finished percentage in the range between 0 and 1.

It must be possible to call this function while assemble is running

Reimplemented in assembler_0_c, and assembler_1_c.

Referenced by solveThread_c::run().

virtual unsigned long assembler_c::getIterations ( void   )  [inline, virtual]

this function returns a number reflecting the complexity of the puzzle.

This could be the number of placements tried, or some other value

Reimplemented in assembler_0_c, and assembler_1_c.

virtual unsigned int assembler_c::getPiecePlacement ( unsigned int  ,
int  ,
unsigned int  ,
unsigned char *  ,
int *  ,
int *  ,
int *   
) const [inline, virtual]

Reimplemented in assembler_0_c, and assembler_1_c.

virtual unsigned int assembler_c::getPiecePlacementCount ( unsigned int   )  const [inline, virtual]

Reimplemented in assembler_0_c, and assembler_1_c.

virtual bool assembler_c::getPiecePlacementSupported ( void   )  const [inline, virtual]

Reimplemented in assembler_0_c, and assembler_1_c.

virtual unsigned int assembler_c::getReducePiece ( void   )  const [inline, virtual]

Then running in an extra thread it is possible to find out which piece is worked on by reduce.

Because the reduce process can take a long time it is nice to give some feedback to the user. With this function the user can get a number to display with the information that the program is currently reducing. The intended interpretation is that the program is currently working on the piece with the returned number, but if you want you can also return something else

Reimplemented in assembler_0_c, and assembler_1_c.

Referenced by solveThread_c::currentActionParameter().

void assembler_c::operator= ( const assembler_c  )  [private]

virtual void assembler_c::reduce ( void   )  [inline, virtual]

Try to optimize piece placement.

the function tries to remove possible piece placements by checking if, after the piece has been placed somewhere, that all the other pieces still can be placed and all holes can still be filled. if this is not the case then this placement can be removed

it is not necessary for an assembler to implement this function

Reimplemented in assembler_0_c, and assembler_1_c.

Referenced by solveThread_c::run().

void assembler_c::save ( xmlWriter_c xml  )  const [virtual]

this function saves the current state of the assembler into an xml node to write it to an file.

this state must be such that the class can restore this state and continue from there by getting this and the puzzle given to the constructor

Reimplemented in assembler_0_c, and assembler_1_c.

References xmlWriter_c::endTag(), and xmlWriter_c::newTag().

Referenced by problem_c::save().

assembler_c::errState assembler_c::setPosition ( const char *  string,
const char *  version 
) [virtual]

sets the position of the assembly process, so that it continues exactly where it stood, when getPosition was called

the function should only be called when assembly is not running it should be called before calling assemble

Reimplemented in assembler_0_c, and assembler_1_c.

References ERR_CAN_NOT_RESTORE_VERSION.

Referenced by problem_c::setAssembler().

virtual void assembler_c::stop ( void   )  [inline, virtual]

stops the assembly process sometimes in the near future.

Reimplemented in assembler_0_c, and assembler_1_c.

Referenced by solveThread_c::stop().

virtual bool assembler_c::stopped ( void   )  const [inline, virtual]

returns true, as soon as the process really has stopped

Reimplemented in assembler_0_c, and assembler_1_c.


The documentation for this class was generated from the following files:

Generated on Sun Oct 10 10:02:42 2010 for BurrTools by  doxygen 1.5.8