The Gaudi Framework  v33r0 (d5ea422b)
IIODataManager.h
Go to the documentation of this file.
1 /***********************************************************************************\
2 * (c) Copyright 1998-2019 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;
79  virtual StatusCode connectWrite( IoType type ) = 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;
112  virtual StatusCode connectWrite( IDataConnection* con, IoType mode = Connection::CREATE,
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
std::string m_name
Connection name/identifier.
IoType
I/O Connection types.
IoStatus
Status Code on bad file connection.
IDataConnection(const IInterface *own, std::string nam)
Standard constructor.
std::string m_fid
File ID of the connection.
std::vector< Connection * > Connections
STL namespace.
const std::string & fid() const
Access file id.
def read(f, regex='.*', skipevents=0)
Definition: hivetimeline.py:33
const IInterface * owner() const
Owner instance.
Connection::IoType IoType
STL class.
const std::string & pfn() const
Access physical file name.
std::string m_pfn
Physical file name of the connection.
void setPFN(std::string fn)
Set physical file name.
int ageFile()
Increase age of I/O source.
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:61
Definition of the basic interface.
Definition: IInterface.h:254
IDataConnection Connection
Connection type definition.
const std::string & name() const
Connection name.
T move(T... args)
#define DeclareInterfaceID(iface, major, minor)
Macro to declare the interface ID when using the new mechanism of extending and implementing interfac...
Definition: IInterface.h:23
int age() const
Access age counter.
void setFID(std::string fid)
Set file ID.
STL class.
ABC describing basic data connection.
void resetAge()
Reset age.
#define GAUDI_API
Definition: Kernel.h:81
Header file for std:chrono::duration-based Counters.
Definition: __init__.py:1