Home | History | Annotate | Download | only in dicnode
      1 /*
      2  * Copyright (C) 2012 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 #ifndef LATINIME_DIC_NODE_STATE_H
     18 #define LATINIME_DIC_NODE_STATE_H
     19 
     20 #include "defines.h"
     21 #include "dic_node_state_input.h"
     22 #include "dic_node_state_output.h"
     23 #include "dic_node_state_prevword.h"
     24 #include "dic_node_state_scoring.h"
     25 
     26 namespace latinime {
     27 
     28 class DicNodeState {
     29  public:
     30     DicNodeStateInput mDicNodeStateInput;
     31     DicNodeStateOutput mDicNodeStateOutput;
     32     DicNodeStatePrevWord mDicNodeStatePrevWord;
     33     DicNodeStateScoring mDicNodeStateScoring;
     34 
     35     AK_FORCE_INLINE DicNodeState()
     36             : mDicNodeStateInput(), mDicNodeStateOutput(), mDicNodeStatePrevWord(),
     37               mDicNodeStateScoring() {
     38     }
     39 
     40     virtual ~DicNodeState() {}
     41 
     42     // Init with prevWordPos
     43     void init(const int prevWordPos) {
     44         mDicNodeStateInput.init();
     45         mDicNodeStateOutput.init();
     46         mDicNodeStatePrevWord.init(prevWordPos);
     47         mDicNodeStateScoring.init();
     48     }
     49 
     50     // Init by copy
     51     AK_FORCE_INLINE void init(const DicNodeState *const src) {
     52         mDicNodeStateInput.init(&src->mDicNodeStateInput);
     53         mDicNodeStateOutput.init(&src->mDicNodeStateOutput);
     54         mDicNodeStatePrevWord.init(&src->mDicNodeStatePrevWord);
     55         mDicNodeStateScoring.init(&src->mDicNodeStateScoring);
     56     }
     57 
     58     // Init by copy and adding subword
     59     void init(const DicNodeState *const src, const uint16_t additionalSubwordLength,
     60             const int *const additionalSubword) {
     61         init(src);
     62         mDicNodeStateOutput.addSubword(additionalSubwordLength, additionalSubword);
     63     }
     64 
     65  private:
     66     // Caution!!!
     67     // Use a default copy constructor and an assign operator because shallow copies are ok
     68     // for this class
     69 };
     70 } // namespace latinime
     71 #endif // LATINIME_DIC_NODE_STATE_H
     72