// Copyright 1997 by Jon Dart.  All Rights Reserved.

#ifndef _PAWN_ENTRY_H
#define _PAWN_ENTRY_H

#include "types.h"
#include "bitmap.h"
#include "square.h"
#include "pool.h"

class Pawn_Entry
{
     // defines one entry in the pawn hash table.

public:

     Pawn_Entry()
     : m_hc(0xffffffff)
     {
     }

     Pawn_Entry( hash_t hc,
                 int score,
                 Square *passers,
                 byte passers_count,
                 const Bitmap &holes,
                 const Bitmap &isolated,
                 int center_score);

     // two entries are equivalent if they have the same hash code bytes.
     BOOL is_equal( const Pawn_Entry &e) const
     {
         return m_hc == e.m_hc;
     }
	    
     hash_t hash_code() const
     {
        return m_hc;
     }
     
     byte get_passers_count() const
     { 
	return m_passers_count;
     }
     
     const Square *get_passers() const
     {
        return m_passers;
     }
     
     const Bitmap &get_holes() const
     {
        return m_holes;
     }
     
     const Bitmap &get_isolated() const
     {
        return m_isolated;
     }
     
     int get_score() const
     {
        return m_score;
     }
     
     int get_center_score() const
     {
        return m_center_score;
     }

    void *operator new (size_t size)
    {
	return allocator.allocate(size);
    }
    
    void *operator new (size_t, void *p)
    {
	return p;    
    }

    void operator delete( void *p )
    {
	allocator.free(p);    
    }
    
    static void freeAll( BOOL final )
    {
	allocator.freeAll(final);
    }
    
private:     
     static Pool allocator;
     hash_t m_hc; // hashcode
     byte m_passers_count;
     Square m_passers[8];
     Bitmap m_holes;
     Bitmap m_isolated;
     int m_score;
     int m_center_score;
};

#endif
