メインページ   モジュール   名前空間一覧   クラス階層   アルファベット順一覧   構成   ファイル一覧   構成メンバ   ファイルメンバ   関連ページ    

TDataInflation.cc

解説を見る。
00001 // =====================================================================
00002 //  $Id: TDataInflation.cc,v 1.5 2004/03/07 16:56:04 goiwai Exp $
00003 //  $Name: CLDAQ-1-14-03 $
00004 //  $Log: TDataInflation.cc,v $
00005 //  Revision 1.5  2004/03/07 16:56:04  goiwai
00006 //  *** empty log message ***
00007 //
00008 //  Revision 1.4  2004/03/07 10:30:34  goiwai
00009 //  ROOTに組みこむためのおまじないマクロを埋めこみました。
00010 //  全てにおいて完全に動作するわけではありません。
00011 //
00012 //  Revision 1.3  2003/10/06 16:38:26  goiwai
00013 //  *** empty log message ***
00014 //
00015 //  Revision 1.2  2003/07/30 16:21:20  goiwai
00016 //  ファイルにコミットログをつけることにしました.
00017 //
00018 // =====================================================================
00019 #ifdef __CLDAQ_ZLIB_USE
00020 #include "TDataInflation.hh"
00021 
00022 TDataInflation::TDataInflation( Tint bufsize )
00023   : theInflationStream(), 
00024     theStatus( Z_OK ),
00025     theOutputBuffer( 0 ), theSizeOfOutputBuffer( bufsize ),
00026     theInflatedData( 0 ), theSizeOfInflatedData( -1 )
00027 {
00028   theInflationStream.zalloc = Z_NULL;
00029   theInflationStream.zfree = Z_NULL;
00030   theInflationStream.opaque = Z_NULL;
00031 
00032   theInflationStream.next_in = Z_NULL;
00033   theInflationStream.avail_in = 0;
00034   theInflationStream.next_out = Z_NULL;
00035   theInflationStream.avail_out = 0;
00036 
00037   theStatus = inflateInit( &theInflationStream );
00038   if ( theStatus != Z_OK ) {
00039     Tcerr << "TDataInflation::TDataInflation: ";
00040     Tcerr << theInflationStream.msg << ", status: " << theStatus << Tendl;
00041   }
00042 
00043   SetOutputBuffer( theSizeOfOutputBuffer );
00044 }
00045 
00046 TDataInflation::TDataInflation( const TDataInflation& right )
00047   : theInflationStream(), 
00048     theStatus( Z_OK ),
00049     theOutputBuffer( 0 ), theSizeOfOutputBuffer( right.theSizeOfOutputBuffer ),
00050     theInflatedData( 0 ), theSizeOfInflatedData( -1 )
00051 {
00052   theInflationStream.zalloc = Z_NULL;
00053   theInflationStream.zfree = Z_NULL;
00054   theInflationStream.opaque = Z_NULL;
00055 
00056   theInflationStream.next_in = Z_NULL;
00057   theInflationStream.avail_in = 0;
00058   theInflationStream.next_out = Z_NULL;
00059   theInflationStream.avail_out = 0;
00060 
00061   theStatus = inflateInit( &theInflationStream );
00062   if ( theStatus != Z_OK ) {
00063     Tcerr << "TDataInflation::TDataInflation: ";
00064     Tcerr << theInflationStream.msg << ", status: " << theStatus << Tendl;
00065   }
00066 
00067   SetOutputBuffer( theSizeOfOutputBuffer );  
00068 }
00069 
00070 TDataInflation::~TDataInflation()
00071 {
00072   theStatus = inflateEnd( &theInflationStream );
00073   if ( theStatus != Z_OK ) {
00074     Tcerr << "TDataInflation::~TDataInflation: ";
00075     Tcerr << theInflationStream.msg << ", status: " << theStatus << Tendl;
00076   }
00077   delete [] theOutputBuffer;
00078 }
00079 const TDataInflation& TDataInflation::operator=( const TDataInflation& right )
00080 {
00081   theInflationStream = right.theInflationStream;
00082   theStatus = right.theStatus;
00083   theSizeOfOutputBuffer = right.theSizeOfOutputBuffer;
00084   delete [] (Tbyte*)theOutputBuffer;
00085   theOutputBuffer = new Tbyte[ theSizeOfOutputBuffer ];
00086   theInflatedData = 0;
00087   theSizeOfInflatedData = -1;
00088   return *this;
00089 }
00090 
00091 Tvoid TDataInflation::Decompress( Tvoid* input, Tint nbyte )
00092 {
00093   static const Tstring head = "TDataInflation::Decompress: ";
00094 
00095   theInflationStream.next_in = (Tbyte*)input;
00096   theInflationStream.avail_in = nbyte;
00097   theInflationStream.next_out = theOutputBuffer;
00098   theInflationStream.avail_out = theSizeOfOutputBuffer;
00099 
00100   theStatus = inflate( &theInflationStream, Z_NO_FLUSH );
00101 
00102   theInflatedData = theOutputBuffer;
00103   theSizeOfInflatedData = theSizeOfOutputBuffer - theInflationStream.avail_out;
00104 
00105   return;
00106 }
00107 
00108 Tvoid TDataInflation::SetOutputBuffer( Tint bufsize )
00109 {
00110   if ( theOutputBuffer ) {
00111     delete [] theOutputBuffer;
00112   }
00113   theOutputBuffer = new Tbyte[ bufsize ];
00114   return;
00115 }
00116 
00117 
00118 #ifdef __CLDAQ_ROOT_DLL
00119     ClassImp(TDataInflation)
00120 #endif
00121 
00122 #endif


CLDAQ - a Class Library for DataAcQuisition (Version 1.14.3)
Go IWAI -- goiwai at users.sourceforge.jp