ATLAS Offline Software
IoSvc.h
Go to the documentation of this file.
1 
3 /*
4  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
5 */
6 
7 // IoSvc.h
8 // Header file for class IoSvc
9 // Author: S.Binet<binet@cern.ch>
11 #ifndef ATHENASERVICES_IOSVC_H
12 #define ATHENASERVICES_IOSVC_H 1
13 
14 // STL includes
15 #include <string>
16 #include <unordered_map>
17 
18 // FrameWork includes
20 
21 // AthenaKernel
23 
24 // Forward declaration
25 class ISvcLocator;
26 template <class TYPE> class SvcFactory;
27 
28 
29 
30 class IoSvc
31  : virtual public ::IIoSvc,
32  public ::AthService
33 {
34  friend class SvcFactory<IoSvc>;
35 
37  // Public methods:
39  public:
40  typedef IIoSvc::Fd Fd;
41 
42  // Copy constructor:
43 
45  IoSvc( const std::string& name, ISvcLocator* pSvcLocator );
46 
48  virtual ~IoSvc();
49 
50  // Assignment operator:
51  //IoSvc &operator=(const IoSvc &alg);
52 
54 
55  virtual StatusCode initialize();
56  virtual StatusCode finalize();
57  virtual StatusCode queryInterface( const InterfaceID& riid,
58  void** ppvInterface );
60 
62  // Const methods:
64 
66  bool has_fd(Fd fd) const;
67 
70  Fd fd(const std::string& fname) const;
71 
74  const std::string& fname(Fd fd) const;
75 
77  IoType mode(Fd fd) const;
78 
80  // Non-const methods:
82 
83  static const InterfaceID& interfaceID();
84 
87  Fd open(const std::string& fname, IoType mode);
88 
91 
93  // Private data:
95  private:
96 
98  IoSvc();
99 
100  struct FdInfos {
101  std::string fname;
103  };
104 
105  typedef std::unordered_map<Fd, FdInfos> FdMap_t;
106 
109 
112 };
113 
114 // I/O operators
116 
118 // Inline methods:
120 
121 inline const InterfaceID& IoSvc::interfaceID()
122 {
123  return IIoSvc::interfaceID();
124 }
125 
126 
127 
128 #endif //> !ATHENASERVICES_IOSVC_H
IoSvc::FdInfos::fname
std::string fname
Definition: IoSvc.h:101
SvcFactory
Definition: AthCnvSvc.h:28
IoSvc::close
StatusCode close(Fd fd)
close file fd
Definition: IoSvc.cxx:165
IIoSvc::interfaceID
static const InterfaceID & interfaceID()
Definition: IIoSvc.h:128
IoSvc::FdInfos::mode
IIoSvc::IoType mode
Definition: IoSvc.h:102
IoSvc
Definition: IoSvc.h:33
IoSvc::FdInfos
Definition: IoSvc.h:100
IoSvc::open
Fd open(const std::string &fname, IoType mode)
open file fname with open mode mode
Definition: IoSvc.cxx:138
IIoSvc
Definition: IIoSvc.h:29
IIoSvc::IoType
IoType
I/O Connection types.
Definition: IIoSvc.h:39
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
IoSvc::m_last_fd
Fd m_last_fd
last created Fd
Definition: IoSvc.h:111
AthService
Definition: AthService.h:32
IoSvc::finalize
virtual StatusCode finalize()
Definition: IoSvc.cxx:58
IoSvc::initialize
virtual StatusCode initialize()
Gaudi Service Implementation.
Definition: IoSvc.cxx:51
IoSvc::has_fd
bool has_fd(Fd fd) const
test if a given file descriptor fd is known to us
Definition: IoSvc.cxx:89
IoSvc::fname
const std::string & fname(Fd fd) const
retrieve the file fname associated with file descriptor fd
Definition: IoSvc.cxx:114
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
IoSvc::~IoSvc
virtual ~IoSvc()
Destructor:
Definition: IoSvc.cxx:46
IoSvc::queryInterface
virtual StatusCode queryInterface(const InterfaceID &riid, void **ppvInterface)
Definition: IoSvc.cxx:71
IoSvc::fd
Fd fd(const std::string &fname) const
retrieve the file descriptor associated with file fname
Definition: IoSvc.cxx:97
IoSvc::FdMap_t
std::unordered_map< Fd, FdInfos > FdMap_t
Definition: IoSvc.h:105
IoSvc::interfaceID
static const InterfaceID & interfaceID()
Definition: IoSvc.h:121
IIoSvc::Fd
int Fd
unix-y file descriptor
Definition: IIoSvc.h:36
AthService.h
IoSvc::Fd
IIoSvc::Fd Fd
Definition: IoSvc.h:40
IoSvc::IoSvc
IoSvc()
Default constructor:
IoSvc::m_fds
FdMap_t m_fds
map of fd->fdinfos
Definition: IoSvc.h:108
IoSvc::mode
IoType mode(Fd fd) const
retrieve the open mode associated with file descriptor fd
Definition: IoSvc.cxx:126
IIoSvc.h