Home | History | Annotate | Download | only in content
      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/probability_dict_content.h
     22  */
     23 
     24 #ifndef LATINIME_BACKWARD_V402_PROBABILITY_DICT_CONTENT_H
     25 #define LATINIME_BACKWARD_V402_PROBABILITY_DICT_CONTENT_H
     26 
     27 #include "defines.h"
     28 #include "dictionary/structure/backward/v402/content/single_dict_content.h"
     29 #include "dictionary/structure/backward/v402/content/terminal_position_lookup_table.h"
     30 #include "dictionary/structure/backward/v402/ver4_dict_constants.h"
     31 #include "dictionary/utils/buffer_with_extendable_buffer.h"
     32 
     33 namespace latinime {
     34 namespace backward {
     35 namespace v402 {
     36 
     37 class ProbabilityEntry;
     38 
     39 class ProbabilityDictContent : public SingleDictContent {
     40  public:
     41     ProbabilityDictContent(const char *const dictPath, const bool hasHistoricalInfo,
     42             const bool isUpdatable)
     43             : SingleDictContent(dictPath, Ver4DictConstants::FREQ_FILE_EXTENSION, isUpdatable),
     44               mHasHistoricalInfo(hasHistoricalInfo),
     45               mSize(getBuffer()->getTailPosition() / getEntrySize()) {}
     46 
     47     ProbabilityDictContent(const bool hasHistoricalInfo)
     48             : mHasHistoricalInfo(hasHistoricalInfo), mSize(0) {}
     49 
     50     const ProbabilityEntry getProbabilityEntry(const int terminalId) const;
     51 
     52     bool setProbabilityEntry(const int terminalId, const ProbabilityEntry *const probabilityEntry);
     53 
     54     bool flushToFile(const char *const dictPath) const;
     55 
     56     bool runGC(const TerminalPositionLookupTable::TerminalIdMap *const terminalIdMap,
     57             const ProbabilityDictContent *const originalProbabilityDictContent);
     58 
     59  private:
     60     DISALLOW_COPY_AND_ASSIGN(ProbabilityDictContent);
     61 
     62     int getEntrySize() const;
     63 
     64     int getEntryPos(const int terminalId) const;
     65 
     66     bool writeEntry(const ProbabilityEntry *const probabilityEntry, const int entryPos);
     67 
     68     bool mHasHistoricalInfo;
     69     int mSize;
     70 };
     71 } // namespace v402
     72 } // namespace backward
     73 } // namespace latinime
     74 #endif /* LATINIME_BACKWARD_V402_PROBABILITY_DICT_CONTENT_H */
     75