#ifndef __HGSANEIMPL_HPP__ #define __HGSANEIMPL_HPP__ #include "HGSane.h" #include "../base/HGInc.h" #include "../base/HGDll.h" #include "../base/HGThread.h" #include "../base/HGLock.h" #include "sane/sane_ex.h" #include "saneui/HGSaneUI.h" #include #include #include class HGSaneManagerImpl { friend class HGSaneSourceImpl; public: HGSaneManagerImpl(); ~HGSaneManagerImpl(); HGResult Create(); HGResult Destroy(); HGResult GetSourceCount(HGUInt *count); HGResult GetSourceName(HGUInt index, HGChar* name, HGUInt maxLen); HGResult OpenSource(HGUInt index, class HGSaneSourceImpl **sourceImpl); HGResult OpenSelectedSource(HGWindow parent, class HGSaneSourceImpl **sourceImpl); private: void RemoveSource(class HGSaneSourceImpl* sourceImpl); private: std::vector> m_vSource; std::list m_listSourceImpl; }; class HGSaneSourceImpl { friend class HGSaneDeviceImpl; public: HGSaneSourceImpl(HGSaneManagerImpl *managerImpl); ~HGSaneSourceImpl(); HGResult Init(const HGChar* saneManu, HGDll dll, f_sane_init fInit, f_sane_exit fExit, const SANEAPI *saneAPI); HGResult Open(const HGChar* saneManu, const HGChar* sanePath); HGResult Close(); HGResult GetName(HGChar* name, HGUInt maxLen); HGResult GetDeviceCount(HGUInt *count); HGResult GetDeviceName(HGUInt index, HGChar* name, HGUInt maxLen); HGResult OpenDevice(HGUInt index, class HGSaneDeviceImpl **deviceImpl, HGChar* errInfo, HGUInt errInfoLen); HGResult OpenSelectedDevice(HGWindow parent, class HGSaneDeviceImpl** deviceImpl); private: HGResult FindFunctions(const HGChar* saneManu); void RemoveDevice(class HGSaneDeviceImpl* deviceImpl); private: HGSaneManagerImpl *m_managerImpl; std::string m_manuName; HGDll m_dll; f_sane_init m_f_sane_init; f_sane_exit m_f_sane_exit; SANEAPI m_saneApi; std::list m_listDeviceImpl; }; class HGSaneDeviceImpl { public: HGSaneDeviceImpl(HGSaneSourceImpl* sourceImpl); ~HGSaneDeviceImpl(); HGResult Init(const HGChar* devName, SANE_Handle handle); HGResult Open(const HGChar *devName, HGChar* errInfo, HGUInt errInfoLen); HGResult Close(); HGResult GetName(HGChar* name, HGUInt maxLen); HGResult ShowSettingDlg(HGWindow parent); HGResult Start(HGSane_DeviceEventFunc eventFunc, HGPointer eventParam, HGSane_DeviceImageFunc imageFunc, HGPointer imageParam, HGChar* errInfo, HGUInt errInfoLen); HGResult Stop(); HGResult StartWithUI(HGWindow parent, HGSane_DeviceImageFunc imageFunc, HGPointer imageParam); private: HGUInt GetDpi(); static void HGAPI ThreadFunc(HGThread thread, HGPointer param); static void ShowScanImageCallback(const SANE_Parameters* imageFormat, const SANE_Byte* imageData, void* callbackParam); private: HGSaneSourceImpl* m_sourceImpl; std::string m_devName; SANE_Handle m_devHandle; HGByte* m_buffer; HGInt m_bufferSize; HGUInt m_dpi; HGSane_DeviceEventFunc m_eventFunc; HGPointer m_eventParam; HGSane_DeviceImageFunc m_imageFunc; HGPointer m_imageParam; volatile HGBool m_stopThread; HGThread m_thread; }; #endif /* __HGSANEIMPL_HPP__ */