Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
TBufferMergerFile.cxx
Go to the documentation of this file.
1 // @(#)root/io:$Id$
2 // Author: Philippe Canal, Witold Pokorski, and Guilherme Amadio
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2017, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 #include "ROOT/TBufferMerger.hxx"
13 
14 #include "TBufferFile.h"
15 
16 namespace ROOT {
17 namespace Experimental {
18 
19 TBufferMergerFile::TBufferMergerFile(TBufferMerger &m)
20  : TMemFile(m.fMerger.GetOutputFile()->GetName(), "RECREATE", "",
21  m.fMerger.GetOutputFile()->GetCompressionSettings()),
22  fMerger(m)
23 {
24 }
25 
26 TBufferMergerFile::~TBufferMergerFile()
27 {
28 }
29 
30 Int_t TBufferMergerFile::Write(const char *name, Int_t opt, Int_t bufsize)
31 {
32  Int_t nbytes = TMemFile::Write(name, opt, bufsize);
33 
34  if (nbytes) {
35  TBufferFile *buffer = new TBufferFile(TBuffer::kWrite, GetSize());
36  CopyTo(*buffer);
37  buffer->SetReadMode();
38  fMerger.Push(buffer);
39  ResetAfterMerge(0);
40  }
41  return nbytes;
42 }
43 
44 } // namespace Experimental
45 } // namespace ROOT