Home | History | Annotate | Download | only in v4
      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 #ifndef LATINIME_VER4_PATRICIA_TRIE_NODE_READER_H
     18 #define LATINIME_VER4_PATRICIA_TRIE_NODE_READER_H
     19 
     20 #include "defines.h"
     21 #include "dictionary/structure/pt_common/pt_node_params.h"
     22 #include "dictionary/structure/pt_common/pt_node_reader.h"
     23 
     24 namespace latinime {
     25 
     26 class BufferWithExtendableBuffer;
     27 class HeaderPolicy;
     28 class LanguageModelDictContent;
     29 
     30 /*
     31  * This class is used for helping to read nodes of ver4 patricia trie. This class handles moved
     32  * node and reads node attributes.
     33  */
     34 class Ver4PatriciaTrieNodeReader : public PtNodeReader {
     35  public:
     36     explicit Ver4PatriciaTrieNodeReader(const BufferWithExtendableBuffer *const buffer)
     37             : mBuffer(buffer) {}
     38 
     39     ~Ver4PatriciaTrieNodeReader() {}
     40 
     41     virtual const PtNodeParams fetchPtNodeParamsInBufferFromPtNodePos(const int ptNodePos) const {
     42         return fetchPtNodeInfoFromBufferAndProcessMovedPtNode(ptNodePos,
     43                 NOT_A_DICT_POS /* siblingNodePos */);
     44     }
     45 
     46  private:
     47     DISALLOW_COPY_AND_ASSIGN(Ver4PatriciaTrieNodeReader);
     48 
     49     const BufferWithExtendableBuffer *const mBuffer;
     50 
     51     const PtNodeParams fetchPtNodeInfoFromBufferAndProcessMovedPtNode(const int ptNodePos,
     52             const int siblingNodePos) const;
     53 };
     54 } // namespace latinime
     55 #endif /* LATINIME_VER4_PATRICIA_TRIE_NODE_READER_H */
     56