00001 00002 // File: ccutil.h 00003 // Description: ccutil class. 00004 // Author: Samuel Charron 00005 // 00006 // (C) Copyright 2006, Google Inc. 00007 // Licensed under the Apache License, Version 2.0 (the "License"); 00008 // you may not use this file except in compliance with the License. 00009 // You may obtain a copy of the License at 00010 // http://www.apache.org/licenses/LICENSE-2.0 00011 // Unless required by applicable law or agreed to in writing, software 00012 // distributed under the License is distributed on an "AS IS" BASIS, 00013 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00014 // See the License for the specific language governing permissions and 00015 // limitations under the License. 00016 // 00018 00019 #ifndef TESSERACT_CCUTIL_CCUTIL_H__ 00020 #define TESSERACT_CCUTIL_CCUTIL_H__ 00021 00022 #include "ambigs.h" 00023 #include "errcode.h" 00024 #include "strngs.h" 00025 #include "tessdatamanager.h" 00026 #include "varable.h" 00027 #include "unicharset.h" 00028 00029 #ifdef WIN32 00030 #include <windows.h> 00031 #else 00032 #include <pthread.h> 00033 #include <semaphore.h> 00034 #endif 00035 00036 namespace tesseract { 00037 00038 class CCUtilMutex { 00039 public: 00040 CCUtilMutex(); 00041 00042 void Lock(); 00043 00044 void Unlock(); 00045 private: 00046 #ifdef WIN32 00047 HANDLE mutex_; 00048 #else 00049 pthread_mutex_t mutex_; 00050 #endif 00051 }; 00052 00053 00054 class CCUtil { 00055 public: 00056 CCUtil(); 00057 ~CCUtil(); 00058 00059 public: 00060 void main_setup( 00061 const char *argv0, // program name 00062 const char *basename // name of image 00063 ); 00064 public: 00065 STRING datadir; // dir for data files 00066 STRING imagebasename; // name of image 00067 00068 BOOL_VAR_H (m_print_variables, FALSE, 00069 "Print initial values of all variables"); 00070 STRING_VAR_H (m_data_sub_dir, "tessdata/", "Directory for data files"); 00071 STRING lang; 00072 STRING language_data_path_prefix; 00073 TessdataManager tessdata_manager; 00074 UNICHARSET unicharset; 00075 UnicharAmbigs unichar_ambigs; 00076 STRING imagefile; // image file name 00077 STRING directory; // main directory 00078 }; 00079 00080 extern CCUtilMutex tprintfMutex; 00081 } // namespace tesseract 00082 00083 #endif // TESSERACT_CCUTIL_CCUTIL_H__