|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include "AlignmentInfoCollection.h" |
|
|
|
|
|
using namespace std; |
|
|
|
|
|
namespace Moses2 |
|
|
{ |
|
|
|
|
|
AlignmentInfoCollection AlignmentInfoCollection::s_instance; |
|
|
|
|
|
AlignmentInfoCollection::AlignmentInfoCollection() |
|
|
{ |
|
|
std::set<std::pair<size_t,size_t> > pairs; |
|
|
m_emptyAlignmentInfo = Add(pairs); |
|
|
} |
|
|
|
|
|
AlignmentInfoCollection::~AlignmentInfoCollection() |
|
|
{} |
|
|
|
|
|
const AlignmentInfo &AlignmentInfoCollection::GetEmptyAlignmentInfo() const |
|
|
{ |
|
|
return *m_emptyAlignmentInfo; |
|
|
} |
|
|
|
|
|
AlignmentInfo const * |
|
|
AlignmentInfoCollection:: |
|
|
Add(AlignmentInfo const& ainfo) |
|
|
{ |
|
|
#ifdef WITH_THREADS |
|
|
{ |
|
|
boost::shared_lock<boost::shared_mutex> read_lock(m_accessLock); |
|
|
AlignmentInfoSet::const_iterator i = m_collection.find(ainfo); |
|
|
if (i != m_collection.end()) |
|
|
return &*i; |
|
|
} |
|
|
boost::unique_lock<boost::shared_mutex> lock(m_accessLock); |
|
|
#endif |
|
|
std::pair<AlignmentInfoSet::iterator, bool> ret = m_collection.insert(ainfo); |
|
|
return &(*ret.first); |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|