tesseract
3.03
|
00001 00002 // File: dawg_cache.h 00003 // Description: A class that knows about loading and caching dawgs. 00004 // Author: David Eger 00005 // Created: Fri Jan 27 12:08:00 PST 2012 00006 // 00007 // (C) Copyright 2012, Google Inc. 00008 // Licensed under the Apache License, Version 2.0 (the "License"); 00009 // you may not use this file except in compliance with the License. 00010 // You may obtain a copy of the License at 00011 // http://www.apache.org/licenses/LICENSE-2.0 00012 // Unless required by applicable law or agreed to in writing, software 00013 // distributed under the License is distributed on an "AS IS" BASIS, 00014 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00015 // See the License for the specific language governing permissions and 00016 // limitations under the License. 00017 // 00019 00020 #ifndef TESSERACT_DICT_DAWG_CACHE_H_ 00021 #define TESSERACT_DICT_DAWG_CACHE_H_ 00022 00023 #include "dawg.h" 00024 #include "object_cache.h" 00025 #include "strngs.h" 00026 #include "tessdatamanager.h" 00027 00028 namespace tesseract { 00029 00030 class DawgCache { 00031 public: 00032 Dawg *GetSquishedDawg( 00033 const STRING &lang, 00034 const char *data_file_name, 00035 TessdataType tessdata_dawg_type, 00036 int debug_level); 00037 00038 // If we manage the given dawg, decrement its count, 00039 // and possibly delete it if the count reaches zero. 00040 // If dawg is unknown to us, return false. 00041 bool FreeDawg(Dawg *dawg) { 00042 return dawgs_.Free(dawg); 00043 } 00044 00045 // Free up any currently unused dawgs. 00046 void DeleteUnusedDawgs() { 00047 dawgs_.DeleteUnusedObjects(); 00048 } 00049 00050 private: 00051 ObjectCache<Dawg> dawgs_; 00052 }; 00053 00054 } // namespace tesseract 00055 00056 #endif // TESSERACT_DICT_DAWG_CACHE_H_