The Gaudi Framework  master (37c0b60a)
IIODataManager.h
Go to the documentation of this file.
1 /***********************************************************************************\
2 * (c) Copyright 1998-2024 CERN for the benefit of the LHCb and ATLAS collaborations *
3 * *
4 * This software is distributed under the terms of the Apache version 2 licence, *
5 * copied verbatim in the file "LICENSE". *
6 * *
7 * In applying this licence, CERN does not waive the privileges and immunities *
8 * granted to it by virtue of its status as an Intergovernmental Organization *
9 * or submit itself to any jurisdiction. *
10 \***********************************************************************************/
11 #ifndef GAUDIUTILS_IIODATAMANAGER_H
12 #define GAUDIUTILS_IIODATAMANAGER_H
13 
14 // Framework include files
15 #include <GaudiKernel/IInterface.h>
16 
17 // C++ include files
18 #include <string>
19 #include <vector>
20 
21 /*
22  * LHCb namespace declaration
23  */
24 namespace Gaudi {
25 
35  protected:
43  int m_age = 0;
45  const IInterface* m_owner = nullptr;
46 
47  public:
49  enum IoType { READ = 1 << 1, UPDATE = 1 << 2, CREATE = 1 << 3, RECREATE = ( 1 << 4 ) + ( 1 << 3 ) };
51  enum IoStatus { BAD_DATA_CONNECTION = 4 };
52 
53  public:
55  IDataConnection( const IInterface* own, std::string nam ) : m_name( std::move( nam ) ), m_owner( own ) {}
57  virtual ~IDataConnection() = default;
59  const std::string& name() const { return m_name; }
61  void setFID( std::string fid ) { m_fid = std::move( fid ); }
63  const std::string& fid() const { return m_fid; }
65  const std::string& pfn() const { return m_pfn; }
67  void setPFN( std::string fn ) { m_pfn = std::move( fn ); }
69  int ageFile() { return ++m_age; }
71  void resetAge() { m_age = 0; }
73  int age() const { return m_age; }
75  const IInterface* owner() const { return m_owner; }
77  virtual StatusCode connectRead() = 0;
81  virtual StatusCode disconnect() = 0;
83  virtual bool isConnected() const = 0;
85  virtual StatusCode read( void* const data, size_t len ) = 0;
87  virtual StatusCode write( const void* data, int len ) = 0;
89  virtual long long int seek( long long int where, int origin ) = 0;
90  };
91 
98  class GAUDI_API IIODataManager : virtual public IInterface {
99  public:
102 
107  enum FileType { UNKNOWN = 1, PFN, LFN, FID };
108 
110  virtual StatusCode connectRead( bool keep_open, IDataConnection* con ) = 0;
113  const std::string& doctype = "UNKNOWN" ) = 0;
115  virtual StatusCode disconnect( IDataConnection* con ) = 0;
117  virtual Connection* connection( const std::string& dsn ) const = 0;
119  virtual Connections connections( const IInterface* owner ) const = 0;
121  virtual StatusCode read( IDataConnection* con, void* const data, size_t len ) = 0;
123  virtual StatusCode write( IDataConnection* con, const void* data, int len ) = 0;
125  virtual long long int seek( IDataConnection* con, long long int where, int origin ) = 0;
126  };
127 } // End namespace Gaudi
128 #endif // GAUDIUTILS_IIODATAMANAGER_H
Gaudi::IDataConnection::name
const std::string & name() const
Connection name.
Definition: IIODataManager.h:59
Gaudi::IDataConnection::ageFile
int ageFile()
Increase age of I/O source.
Definition: IIODataManager.h:69
Gaudi::IIODataManager::read
virtual StatusCode read(IDataConnection *con, void *const data, size_t len)=0
Read raw byte buffer from input stream.
std::string
STL class.
std::move
T move(T... args)
Gaudi::IDataConnection::setFID
void setFID(std::string fid)
Set file ID.
Definition: IIODataManager.h:61
Gaudi::IDataConnection
Definition: IIODataManager.h:34
std::vector
STL class.
Gaudi::IDataConnection::age
int age() const
Access age counter.
Definition: IIODataManager.h:73
Gaudi::IDataConnection::resetAge
void resetAge()
Reset age.
Definition: IIODataManager.h:71
Gaudi::IIODataManager::Connection
IDataConnection Connection
Connection type definition.
Definition: IIODataManager.h:104
Gaudi::IDataConnection::seek
virtual long long int seek(long long int where, int origin)=0
Seek on the file described by ioDesc. Arguments as in ::seek()
Gaudi::IDataConnection::connectRead
virtual StatusCode connectRead()=0
Open data stream in read mode.
Gaudi::IIODataManager::connections
virtual Connections connections(const IInterface *owner) const =0
Get connection by owner instance (0=ALL)
Gaudi::IDataConnection::~IDataConnection
virtual ~IDataConnection()=default
Standard destructor.
StatusCode
Definition: StatusCode.h:65
IInterface.h
Gaudi::IIODataManager::FileType
FileType
Definition: IIODataManager.h:107
Gaudi::IIODataManager::connection
virtual Connection * connection(const std::string &dsn) const =0
Retrieve known connection.
Io::UNKNOWN
@ UNKNOWN
Definition: IFileMgr.h:156
Gaudi::IDataConnection::disconnect
virtual StatusCode disconnect()=0
Release data stream.
Gaudi::IIODataManager::IoType
Connection::IoType IoType
Definition: IIODataManager.h:106
Gaudi::IDataConnection::m_name
std::string m_name
Connection name/identifier.
Definition: IIODataManager.h:37
Gaudi::IDataConnection::isConnected
virtual bool isConnected() const =0
Check if connected to data source.
Gaudi::IDataConnection::IoType
IoType
I/O Connection types.
Definition: IIODataManager.h:49
Gaudi::IDataConnection::IDataConnection
IDataConnection(const IInterface *own, std::string nam)
Standard constructor.
Definition: IIODataManager.h:55
Gaudi::IDataConnection::m_fid
std::string m_fid
File ID of the connection.
Definition: IIODataManager.h:39
Gaudi::IDataConnection::connectWrite
virtual StatusCode connectWrite(IoType type)=0
Open data stream in write mode.
Gaudi
This file provides a Grammar for the type Gaudi::Accumulators::Axis It allows to use that type from p...
Definition: __init__.py:1
Gaudi::IIODataManager::disconnect
virtual StatusCode disconnect(IDataConnection *con)=0
Release data stream.
Gaudi::IIODataManager::connectWrite
virtual StatusCode connectWrite(IDataConnection *con, IoType mode=Connection::CREATE, const std::string &doctype="UNKNOWN")=0
Open data stream in write mode.
Gaudi::IIODataManager::write
virtual StatusCode write(IDataConnection *con, const void *data, int len)=0
Write raw byte buffer to output stream.
Gaudi::IDataConnection::IoStatus
IoStatus
Status Code on bad file connection.
Definition: IIODataManager.h:51
gaudirun.type
type
Definition: gaudirun.py:160
Gaudi::IIODataManager::connectRead
virtual StatusCode connectRead(bool keep_open, IDataConnection *con)=0
Open data stream in read mode.
std
STL namespace.
Io::CREATE
@ CREATE
Definition: IFileMgr.h:41
IInterface
Definition: IInterface.h:239
Gaudi::IDataConnection::fid
const std::string & fid() const
Access file id.
Definition: IIODataManager.h:63
Gaudi::IIODataManager::DeclareInterfaceID
DeclareInterfaceID(IIODataManager, 2, 0)
InterfaceID.
Gaudi::IDataConnection::owner
const IInterface * owner() const
Owner instance.
Definition: IIODataManager.h:75
Gaudi::IDataConnection::m_pfn
std::string m_pfn
Physical file name of the connection.
Definition: IIODataManager.h:41
Gaudi::IDataConnection::pfn
const std::string & pfn() const
Access physical file name.
Definition: IIODataManager.h:65
Gaudi::IDataConnection::setPFN
void setPFN(std::string fn)
Set physical file name.
Definition: IIODataManager.h:67
Gaudi::IDataConnection::write
virtual StatusCode write(const void *data, int len)=0
Write raw byte buffer to output stream.
Gaudi::IIODataManager
Definition: IIODataManager.h:98
Gaudi::IIODataManager::seek
virtual long long int seek(IDataConnection *con, long long int where, int origin)=0
Seek on the file described by ioDesc. Arguments as in ::seek()
GAUDI_API
#define GAUDI_API
Definition: Kernel.h:81
Io::READ
@ READ
Definition: IFileMgr.h:37
Gaudi::IIODataManager::Connections
std::vector< Connection * > Connections
Definition: IIODataManager.h:105
Gaudi::IDataConnection::read
virtual StatusCode read(void *const data, size_t len)=0
Read raw byte buffer from input stream.