1 /*
2  * Copyright (C) 2013, The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 /*
18  * !!!!! DO NOT EDIT THIS FILE !!!!!
19  *
20  * This file was generated from
21  *   dictionary/structure/v4/content/bigram_entry.h
22  */
23 
24 #ifndef LATINIME_BACKWARD_V402_BIGRAM_ENTRY_H
25 #define LATINIME_BACKWARD_V402_BIGRAM_ENTRY_H
26 
27 #include "defines.h"
28 #include "dictionary/property/historical_info.h"
29 #include "dictionary/structure/backward/v402/ver4_dict_constants.h"
30 
31 namespace latinime {
32 namespace backward {
33 namespace v402 {
34 
35 class BigramEntry {
36  public:
BigramEntry(const BigramEntry & bigramEntry)37     BigramEntry(const BigramEntry& bigramEntry)
38             : mHasNext(bigramEntry.mHasNext), mProbability(bigramEntry.mProbability),
39               mHistoricalInfo(), mTargetTerminalId(bigramEntry.mTargetTerminalId) {}
40 
41     // Entry with historical information.
BigramEntry(const bool hasNext,const int probability,const int targetTerminalId)42     BigramEntry(const bool hasNext, const int probability, const int targetTerminalId)
43             : mHasNext(hasNext), mProbability(probability), mHistoricalInfo(),
44               mTargetTerminalId(targetTerminalId) {}
45 
46     // Entry with historical information.
BigramEntry(const bool hasNext,const int probability,const HistoricalInfo * const historicalInfo,const int targetTerminalId)47     BigramEntry(const bool hasNext, const int probability,
48             const HistoricalInfo *const historicalInfo, const int targetTerminalId)
49             : mHasNext(hasNext), mProbability(probability), mHistoricalInfo(*historicalInfo),
50               mTargetTerminalId(targetTerminalId) {}
51 
getInvalidatedEntry()52     const BigramEntry getInvalidatedEntry() const {
53         return updateTargetTerminalIdAndGetEntry(Ver4DictConstants::NOT_A_TERMINAL_ID);
54     }
55 
updateHasNextAndGetEntry(const bool hasNext)56     const BigramEntry updateHasNextAndGetEntry(const bool hasNext) const {
57         return BigramEntry(hasNext, mProbability, &mHistoricalInfo, mTargetTerminalId);
58     }
59 
updateTargetTerminalIdAndGetEntry(const int newTargetTerminalId)60     const BigramEntry updateTargetTerminalIdAndGetEntry(const int newTargetTerminalId) const {
61         return BigramEntry(mHasNext, mProbability, &mHistoricalInfo, newTargetTerminalId);
62     }
63 
updateProbabilityAndGetEntry(const int probability)64     const BigramEntry updateProbabilityAndGetEntry(const int probability) const {
65         return BigramEntry(mHasNext, probability, &mHistoricalInfo, mTargetTerminalId);
66     }
67 
updateHistoricalInfoAndGetEntry(const HistoricalInfo * const historicalInfo)68     const BigramEntry updateHistoricalInfoAndGetEntry(
69             const HistoricalInfo *const historicalInfo) const {
70         return BigramEntry(mHasNext, mProbability, historicalInfo, mTargetTerminalId);
71     }
72 
isValid()73     bool isValid() const {
74         return mTargetTerminalId != Ver4DictConstants::NOT_A_TERMINAL_ID;
75     }
76 
hasNext()77     bool hasNext() const {
78         return mHasNext;
79     }
80 
getProbability()81     int getProbability() const {
82         return mProbability;
83     }
84 
hasHistoricalInfo()85     bool hasHistoricalInfo() const {
86         return mHistoricalInfo.isValid();
87     }
88 
getHistoricalInfo()89     const HistoricalInfo *getHistoricalInfo() const {
90         return &mHistoricalInfo;
91     }
92 
getTargetTerminalId()93     int getTargetTerminalId() const {
94         return mTargetTerminalId;
95     }
96 
97  private:
98     // Copy constructor is public to use this class as a type of return value.
99     DISALLOW_DEFAULT_CONSTRUCTOR(BigramEntry);
100     DISALLOW_ASSIGNMENT_OPERATOR(BigramEntry);
101 
102     const bool mHasNext;
103     const int mProbability;
104     const HistoricalInfo mHistoricalInfo;
105     const int mTargetTerminalId;
106 };
107 } // namespace v402
108 } // namespace backward
109 } // namespace latinime
110 #endif /* LATINIME_BACKWARD_V402_BIGRAM_ENTRY_H */
111