ATLAS Offline Software
Loading...
Searching...
No Matches
IIoSvc.h
Go to the documentation of this file.
1
2
3/*
4 Copyright (C) 2002-2024 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
27class IIoSvc
28 : virtual public ::IService
29{
31 // Public typedef:
33public:
36
38 typedef int Fd;
39
41 enum IoType {
43 READ = 1<<1,
44 UPDATE = 1<<2,
45 CREATE = 1<<3,
46 RECREATE = (1<<4)+(1<<3)
47 };
48
49 static
50 const std::string& IoTypeName(IoType mode) {
51 static std::map<IoType, std::string> s_names;
52 if (s_names.empty()) {
53 s_names[INVALID] = "";
54 s_names[READ] = "READ";
55 s_names[UPDATE] = "UPDATE";
56 s_names[CREATE] = "CREATE";
57 s_names[RECREATE] = "RECREATE";
58 }
59 return s_names[mode];
60 }
61
62 static
63 IoType IoTypeFromName(const std::string& name) {
64 static std::map<std::string, IoType> s_names;
65 if (s_names.empty()) {
66 s_names[""] = INVALID;
67 s_names["READ"] = READ;
68 s_names["UPDATE"] = UPDATE;
69 s_names["CREATE"] = CREATE;
70 s_names["RECREATE"] = RECREATE;
71 }
72 return s_names[name];
73 }
74
76 // Public methods:
78public:
79
82 virtual ~IIoSvc();
83
85 // Const methods:
87
89 // Non-const methods:
91
94 virtual
95 Fd open(const std::string& fname, IoType mode) = 0;
96
98 virtual
99 StatusCode close(Fd fd) = 0;
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#endif //> !ATHENAKERNEL_IIOSVC_H
is a registry of file handles, storing their name and openmode.
Definition IIoSvc.h:29
virtual IoType mode(Fd fd) const =0
retrieve the open mode associated with file descriptor fd
IoType
I/O Connection types.
Definition IIoSvc.h:41
@ READ
Definition IIoSvc.h:43
@ CREATE
Definition IIoSvc.h:45
@ UPDATE
Definition IIoSvc.h:44
@ RECREATE
Definition IIoSvc.h:46
@ INVALID
Definition IIoSvc.h:42
virtual StatusCode close(Fd fd)=0
close file fd
int Fd
unix-y file descriptor
Definition IIoSvc.h:38
virtual bool has_fd(Fd fd) const =0
test if a given file descriptor fd is known to us
virtual Fd open(const std::string &fname, IoType mode)=0
open file fname with open mode mode
DeclareInterfaceID(IIoSvc, 1, 0)
InterfaceID.
virtual Fd fd(const std::string &fname) const =0
retrieve the file descriptor associated with file fname
virtual const std::string & fname(Fd fd) const =0
retrieve the file fname associated with file descriptor fd
static const std::string & IoTypeName(IoType mode)
Definition IIoSvc.h:50
static IoType IoTypeFromName(const std::string &name)
Definition IIoSvc.h:63
virtual ~IIoSvc()
Destructor:
Definition IIoSvc.cxx:17