1 // HandlerOut.h 2 3 #ifndef __HANDLER_OUT_H 4 #define __HANDLER_OUT_H 5 6 #include "../../../Windows/System.h" 7 8 #include "../../Common/MethodProps.h" 9 10 namespace NArchive { 11 12 bool ParseSizeString(const wchar_t *name, const PROPVARIANT &prop, UInt64 percentsBase, UInt64 &res); 13 14 class CCommonMethodProps 15 { 16 protected: 17 void InitCommon() 18 { 19 #ifndef _7ZIP_ST 20 _numProcessors = _numThreads = NWindows::NSystem::GetNumberOfProcessors(); 21 #endif 22 23 UInt64 memAvail = (UInt64)(sizeof(size_t)) << 28; 24 _memAvail = memAvail; 25 _memUsage = memAvail; 26 if (NWindows::NSystem::GetRamSize(memAvail)) 27 { 28 _memAvail = memAvail; 29 _memUsage = memAvail / 32 * 17; 30 } 31 } 32 33 public: 34 #ifndef _7ZIP_ST 35 UInt32 _numThreads; 36 UInt32 _numProcessors; 37 #endif 38 39 UInt64 _memUsage; 40 UInt64 _memAvail; 41 42 bool SetCommonProperty(const UString &name, const PROPVARIANT &value, HRESULT &hres); 43 44 CCommonMethodProps() { InitCommon(); } 45 }; 46 47 48 #ifndef EXTRACT_ONLY 49 50 class CMultiMethodProps: public CCommonMethodProps 51 { 52 UInt32 _level; 53 int _analysisLevel; 54 55 void InitMulti(); 56 public: 57 UInt32 _crcSize; 58 CObjectVector<COneMethodInfo> _methods; 59 COneMethodInfo _filterMethod; 60 bool _autoFilter; 61 62 63 void SetGlobalLevelTo(COneMethodInfo &oneMethodInfo) const; 64 65 #ifndef _7ZIP_ST 66 static void SetMethodThreadsTo(COneMethodInfo &oneMethodInfo, UInt32 numThreads); 67 #endif 68 69 70 unsigned GetNumEmptyMethods() const 71 { 72 unsigned i; 73 for (i = 0; i < _methods.Size(); i++) 74 if (!_methods[i].IsEmpty()) 75 break; 76 return i; 77 } 78 79 int GetLevel() const { return _level == (UInt32)(Int32)-1 ? 5 : (int)_level; } 80 int GetAnalysisLevel() const { return _analysisLevel; } 81 82 void Init(); 83 CMultiMethodProps() { InitMulti(); } 84 85 HRESULT SetProperty(const wchar_t *name, const PROPVARIANT &value); 86 }; 87 88 89 class CSingleMethodProps: public COneMethodInfo, public CCommonMethodProps 90 { 91 UInt32 _level; 92 93 void InitSingle() 94 { 95 _level = (UInt32)(Int32)-1; 96 } 97 98 public: 99 void Init(); 100 CSingleMethodProps() { InitSingle(); } 101 102 int GetLevel() const { return _level == (UInt32)(Int32)-1 ? 5 : (int)_level; } 103 HRESULT SetProperties(const wchar_t * const *names, const PROPVARIANT *values, UInt32 numProps); 104 }; 105 106 #endif 107 108 } 109 110 #endif 111