CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_2_SLHC4_patch1/src/Utilities/StorageFactory/src/IOChannel.cc

Go to the documentation of this file.
00001 #include "Utilities/StorageFactory/interface/IOChannel.h"
00002 #include "Utilities/StorageFactory/src/Throw.h"
00003 #include <algorithm>
00004 #include <cassert>
00005 
00031 
00032 
00033 
00034 
00057 
00058 
00059 
00060 
00061 IOChannel::IOChannel (IOFD fd /* = EDM_IOFD_INVALID */)
00062   : m_fd (fd)
00063 {}
00064 
00065 IOChannel::~IOChannel (void)
00066 {}
00067 
00071 
00072 IOFD
00073 IOChannel::fd (void) const
00074 { return m_fd; }
00075 
00078 void
00079 IOChannel::fd (IOFD value)
00080 {
00081   // FIXME: close old one?
00082   // FIXME: reset state?
00083   m_fd = value;
00084 }
00085 
00089 
00091 void
00092 IOChannel::close (void)
00093 {
00094   if (fd () == EDM_IOFD_INVALID)
00095     return;
00096 
00097   int error = 0;
00098   if (! sysclose (fd (), &error))
00099     throwStorageError ("FileCloseError", "Calling IOChannel::close()",
00100                        "sysclose()", error);
00101 
00102   fd (EDM_IOFD_INVALID);
00103 }