Simpatico  v1.10
BinaryFileOArchive.cpp
1 /*
2 * Util Package - C++ Utilities for Scientific Computation
3 *
4 * Copyright 2010 - 2017, The Regents of the University of Minnesota
5 * Distributed under the terms of the GNU General Public License.
6 */
7 
8 #include "BinaryFileOArchive.h"
9 
10 namespace Util
11 {
12 
13  /*
14  * Constructor.
15  */
17  : filePtr_(0),
18  version_(0),
19  createdFile_(true)
20  { filePtr_ = new std::ofstream(); }
21 
22  /*
23  * Constructor.
24  */
26  : filePtr_(0),
27  version_(0),
28  createdFile_(true)
29  { filePtr_ = new std::ofstream(filename.c_str()); }
30 
31  /*
32  * Constructor.
33  */
35  : filePtr_(&file),
36  version_(0),
37  createdFile_(false)
38  {}
39 
40  /*
41  * Destructor.
42  */
44  {
45  if (filePtr_ && createdFile_) {
46  delete filePtr_;
47  }
48  }
49 
50  /*
51  * Return underlying file by reference.
52  */
53  std::ofstream& BinaryFileOArchive::file()
54  { return *filePtr_; }
55 
56 }
Utility classes for scientific computation.
Definition: accumulators.mod:1
virtual ~BinaryFileOArchive()
Destructor.
std::ofstream & file()
Get the underlying ifstream by reference.