Upload 2.0.2
[physicsfs] / lzma / CPP / 7zip / Archive / Common / CoderMixer2MT.h
1 // CoderMixer2MT.h
2
3 #ifndef __CODER_MIXER2_MT_H
4 #define __CODER_MIXER2_MT_H
5
6 #include "CoderMixer2.h"
7 #include "../../../Common/MyCom.h"
8 #include "../../Common/StreamBinder.h"
9 #include "../../Common/VirtThread.h"
10
11 namespace NCoderMixer {
12
13 struct CCoder2: public CCoderInfo2, public CVirtThread
14 {
15   HRESULT Result;
16   CObjectVector< CMyComPtr<ISequentialInStream> > InStreams;
17   CObjectVector< CMyComPtr<ISequentialOutStream> > OutStreams;
18   CRecordVector<ISequentialInStream*> InStreamPointers;
19   CRecordVector<ISequentialOutStream*> OutStreamPointers;
20
21   CCoder2(UInt32 numInStreams, UInt32 numOutStreams);
22   void SetCoderInfo(const UInt64 **inSizes, const UInt64 **outSizes);
23   virtual void Execute();
24   void Code(ICompressProgressInfo *progress);
25 };
26
27
28 /*
29   SetBindInfo()
30   for each coder
31     AddCoder[2]()
32   SetProgressIndex(UInt32 coderIndex);
33  
34   for each file
35   {
36     ReInit()
37     for each coder
38       SetCoderInfo  
39     Code
40   }
41 */
42
43 class CCoderMixer2MT:
44   public ICompressCoder2,
45   public CCoderMixer2,
46   public CMyUnknownImp
47 {
48   CBindInfo _bindInfo;
49   CObjectVector<CStreamBinder> _streamBinders;
50   int _progressCoderIndex;
51
52   void AddCoderCommon();
53   HRESULT Init(ISequentialInStream **inStreams, ISequentialOutStream **outStreams);
54   HRESULT ReturnIfError(HRESULT code);
55 public:
56   CObjectVector<CCoder2> _coders;
57   MY_UNKNOWN_IMP
58
59   STDMETHOD(Code)(ISequentialInStream **inStreams,
60       const UInt64 **inSizes, 
61       UInt32 numInStreams,
62       ISequentialOutStream **outStreams, 
63       const UInt64 **outSizes,
64       UInt32 numOutStreams,
65       ICompressProgressInfo *progress);
66
67   HRESULT SetBindInfo(const CBindInfo &bindInfo);
68   void AddCoder(ICompressCoder *coder);
69   void AddCoder2(ICompressCoder2 *coder);
70   void SetProgressCoderIndex(int coderIndex) {  _progressCoderIndex = coderIndex; }
71
72   void ReInit();
73   void SetCoderInfo(UInt32 coderIndex, const UInt64 **inSizes, const UInt64 **outSizes)
74     {  _coders[coderIndex].SetCoderInfo(inSizes, outSizes); }
75   UInt64 GetWriteProcessedSize(UInt32 binderIndex) const
76     {  return _streamBinders[binderIndex].ProcessedSize; }
77 };
78
79 }
80 #endif