summaryrefslogtreecommitdiff
path: root/vest/scorer.h
diff options
context:
space:
mode:
authorgraehl <graehl@ec762483-ff6d-05da-a07a-a48fb63a330f>2010-07-21 20:12:44 +0000
committergraehl <graehl@ec762483-ff6d-05da-a07a-a48fb63a330f>2010-07-21 20:12:44 +0000
commitf80891a7c4a2834efc476ce4d29cc6c438e567f0 (patch)
tree44256925313682feb6beb7bb701b2d4624de5f48 /vest/scorer.h
parent37043945bebecad62af028f76549245ba020884e (diff)
Score::Clone() via CRTP
git-svn-id: https://ws10smt.googlecode.com/svn/trunk@360 ec762483-ff6d-05da-a07a-a48fb63a330f
Diffstat (limited to 'vest/scorer.h')
-rw-r--r--vest/scorer.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/vest/scorer.h b/vest/scorer.h
index 0d90f378..0c8b380f 100644
--- a/vest/scorer.h
+++ b/vest/scorer.h
@@ -46,6 +46,18 @@ class Score : public boost::intrusive_refcount<Score> {
virtual void Encode(std::string* out) const = 0;
static ScoreP GetZero(ScoreType type);
static ScoreP GetOne(ScoreType type);
+ virtual ScoreP Clone() const = 0;
+protected:
+ Score() { } // we define these explicitly because refcount is noncopyable
+ Score(Score const& o) { }
+};
+
+//TODO: make sure default copy ctors for score types do what we want.
+template <class Derived>
+struct ScoreBase : public Score {
+ ScoreP Clone() const {
+ return ScoreP(new Derived(dynamic_cast<Derived const&>(*this)));
+ }
};
class SentenceScorer {