ATLAS Offline Software
IIoSvc.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 // IIoSvc.h
8 // Header file for class IIoSvc
9 // Author: S.Binet<binet@cern.ch>
11 #ifndef ATHENAKERNEL_IIOSVC_H
12 #define ATHENAKERNEL_IIOSVC_H 1
13 
14 // STL includes
15 #include <string>
16 
17 // FrameWork includes
18 #include "GaudiKernel/IService.h"
19 
20 // AthenaKernel includes
21 
22 
27 class IIoSvc
28  : virtual public ::IService
29 {
31  // Public typedef:
33 public:
34 
36  typedef int Fd;
37 
39  enum IoType {
40  INVALID = 0,
41  READ = 1<<1,
42  UPDATE = 1<<2,
43  CREATE = 1<<3,
44  RECREATE = (1<<4)+(1<<3)
45  };
46 
47  static
48  const std::string& IoTypeName(IoType mode) {
49  static std::map<IoType, std::string> s_names;
50  if (s_names.empty()) {
51  s_names[INVALID] = "";
52  s_names[READ] = "READ";
53  s_names[UPDATE] = "UPDATE";
54  s_names[CREATE] = "CREATE";
55  s_names[RECREATE] = "RECREATE";
56  }
57  return s_names[mode];
58  }
59 
60  static
61  IoType IoTypeFromName(const std::string& name) {
62  static std::map<std::string, IoType> s_names;
63  if (s_names.empty()) {
64  s_names[""] = INVALID;
65  s_names["READ"] = READ;
66  s_names["UPDATE"] = UPDATE;
67  s_names["CREATE"] = CREATE;
68  s_names["RECREATE"] = RECREATE;
69  }
70  return s_names[name];
71  }
72 
74  // Public methods:
76 public:
77 
80  virtual ~IIoSvc();
81 
83  // Const methods:
85 
87  // Non-const methods:
89 
90  static const InterfaceID& interfaceID();
91 
94  virtual
95  Fd open(const std::string& fname, IoType mode) = 0;
96 
98  virtual
100 
102  virtual
103  bool has_fd(Fd fd) const = 0;
104 
107  virtual
108  Fd fd(const std::string& fname) const = 0;
109 
112  virtual
113  const std::string& fname(Fd fd) const = 0;
114 
116  virtual
117  IoType mode(Fd fd) const = 0;
118 
119 };
120 
121 // I/O operators
123 
125 // Inline methods:
127 
128 inline const InterfaceID& IIoSvc::interfaceID()
129 {
130  static const InterfaceID IID_IIoSvc("IIoSvc", 1, 0);
131  return IID_IIoSvc;
132 }
133 
134 
135 #endif //> !ATHENAKERNEL_IIOSVC_H
IIoSvc::IoTypeName
static const std::string & IoTypeName(IoType mode)
Definition: IIoSvc.h:48
IIoSvc::open
virtual Fd open(const std::string &fname, IoType mode)=0
open file fname with open mode mode
IIoSvc::~IIoSvc
virtual ~IIoSvc()
Destructor:
Definition: IIoSvc.cxx:17
IIoSvc::has_fd
virtual bool has_fd(Fd fd) const =0
test if a given file descriptor fd is known to us
IIoSvc::RECREATE
@ RECREATE
Definition: IIoSvc.h:44
IIoSvc::interfaceID
static const InterfaceID & interfaceID()
Definition: IIoSvc.h:128
IIoSvc::fname
virtual const std::string & fname(Fd fd) const =0
retrieve the file fname associated with file descriptor fd
IIoSvc
Definition: IIoSvc.h:29
IIoSvc::IoType
IoType
I/O Connection types.
Definition: IIoSvc.h:39
IIoSvc::close
virtual StatusCode close(Fd fd)=0
close file fd
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
IIoSvc::CREATE
@ CREATE
Definition: IIoSvc.h:43
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
IIoSvc::IoTypeFromName
static IoType IoTypeFromName(const std::string &name)
Definition: IIoSvc.h:61
IIoSvc::UPDATE
@ UPDATE
Definition: IIoSvc.h:42
IIoSvc::mode
virtual IoType mode(Fd fd) const =0
retrieve the open mode associated with file descriptor fd
IIoSvc::Fd
int Fd
unix-y file descriptor
Definition: IIoSvc.h:36
IIoSvc::READ
@ READ
Definition: IIoSvc.h:41
IIoSvc::fd
virtual Fd fd(const std::string &fname) const =0
retrieve the file descriptor associated with file fname
IIoSvc::INVALID
@ INVALID
Definition: IIoSvc.h:40