File indexing completed on 2025-01-18 09:57:46
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #ifndef GAUDIUTILS_IIODATAMANAGER_H
0012 #define GAUDIUTILS_IIODATAMANAGER_H
0013
0014
0015 #include "GaudiKernel/IInterface.h"
0016
0017
0018 #include <string>
0019 #include <vector>
0020
0021
0022
0023
0024 namespace Gaudi {
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034 class GAUDI_API IDataConnection {
0035 protected:
0036
0037 std::string m_name;
0038
0039 std::string m_fid;
0040
0041 std::string m_pfn;
0042
0043 int m_age = 0;
0044
0045 const IInterface* m_owner = nullptr;
0046
0047 public:
0048
0049 enum IoType { READ = 1 << 1, UPDATE = 1 << 2, CREATE = 1 << 3, RECREATE = ( 1 << 4 ) + ( 1 << 3 ) };
0050
0051 enum IoStatus { BAD_DATA_CONNECTION = 4 };
0052
0053 public:
0054
0055 IDataConnection( const IInterface* own, std::string nam ) : m_name( std::move( nam ) ), m_owner( own ) {}
0056
0057 virtual ~IDataConnection() = default;
0058
0059 const std::string& name() const { return m_name; }
0060
0061 void setFID( std::string fid ) { m_fid = std::move( fid ); }
0062
0063 const std::string& fid() const { return m_fid; }
0064
0065 const std::string& pfn() const { return m_pfn; }
0066
0067 void setPFN( std::string fn ) { m_pfn = std::move( fn ); }
0068
0069 int ageFile() { return ++m_age; }
0070
0071 void resetAge() { m_age = 0; }
0072
0073 int age() const { return m_age; }
0074
0075 const IInterface* owner() const { return m_owner; }
0076
0077 virtual StatusCode connectRead() = 0;
0078
0079 virtual StatusCode connectWrite( IoType type ) = 0;
0080
0081 virtual StatusCode disconnect() = 0;
0082
0083 virtual bool isConnected() const = 0;
0084
0085 virtual StatusCode read( void* const data, size_t len ) = 0;
0086
0087 virtual StatusCode write( const void* data, int len ) = 0;
0088
0089 virtual long long int seek( long long int where, int origin ) = 0;
0090 };
0091
0092
0093
0094
0095
0096
0097
0098 class GAUDI_API IIODataManager : virtual public IInterface {
0099 public:
0100
0101 DeclareInterfaceID( IIODataManager, 2, 0 );
0102
0103
0104 typedef IDataConnection Connection;
0105 typedef std::vector<Connection*> Connections;
0106 typedef Connection::IoType IoType;
0107 enum FileType { UNKNOWN = 1, PFN, LFN, FID };
0108
0109
0110 virtual StatusCode connectRead( bool keep_open, IDataConnection* con ) = 0;
0111
0112 virtual StatusCode connectWrite( IDataConnection* con, IoType mode = Connection::CREATE,
0113 const std::string& doctype = "UNKNOWN" ) = 0;
0114
0115 virtual StatusCode disconnect( IDataConnection* con ) = 0;
0116
0117 virtual Connection* connection( const std::string& dsn ) const = 0;
0118
0119 virtual Connections connections( const IInterface* owner ) const = 0;
0120
0121 virtual StatusCode read( IDataConnection* con, void* const data, size_t len ) = 0;
0122
0123 virtual StatusCode write( IDataConnection* con, const void* data, int len ) = 0;
0124
0125 virtual long long int seek( IDataConnection* con, long long int where, int origin ) = 0;
0126 };
0127 }
0128 #endif