/**
 * \class BDUniquify
 *
 * \ingroup BeamDataUtil
 *
 * \brief Pull out not recently seen RawBeamMonBlocks from Mom.
 *
 * Unfortunately there was a period of time where multiple callbacks
 * were set in the bdp-server.  This resulted in almost two weeks of
 * data taking where there will be multiple spills in mom when the
 * data is read back.  This class tries to clean things up as best as
 * possible.  It does this by remembering the last N VldTimeStamps and
 * returning only those RawBeamMonBlocks that have VldTimeStamps that
 * are not near any of the last ones. 
 *
 * \author (last to touch it) $Author: bv $
 *
 * \version $Revision: 1.1 $
 *
 * \date $Date: 2005/11/07 21:35:21 $
 *
 * Contact: bv@bnl.gov
 *
 * Created on: Mon Nov  7 10:28:11 2005
 *
 * $Id: BDUniquify.h,v 1.1 2005/11/07 21:35:21 bv Exp $
 *
 */



#ifndef BDUNIQUIFY_H
#define BDUNIQUIFY_H

#include <Validity/VldTimeStamp.h>

#include <map>
#include <deque>
#include <vector>

class RawBeamMonBlock;
class RawBeamMonHeaderBlock;
class MomNavigator;

class BDUniquify {
    std::map<int,std::deque<VldTimeStamp> > fPastSpills;
    size_t fSize;

public:
    BDUniquify(size_t qsize = 10);

    typedef std::pair<const RawBeamMonHeaderBlock*,const RawBeamMonBlock*> BlockPair;
    std::vector<BlockPair> GetUniqueBlocks(const MomNavigator &mom);
    bool IsUnique(const VldTimeStamp& vts, int event, int delay);
    void AddTimeStamp(const VldTimeStamp& vts, int event, int delay);
};

#endif  // BDUNIQUIFY_H
