Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:57:46

0001 /***********************************************************************************\
0002 * (c) Copyright 1998-2019 CERN for the benefit of the LHCb and ATLAS collaborations *
0003 *                                                                                   *
0004 * This software is distributed under the terms of the Apache version 2 licence,     *
0005 * copied verbatim in the file "LICENSE".                                            *
0006 *                                                                                   *
0007 * In applying this licence, CERN does not waive the privileges and immunities       *
0008 * granted to it by virtue of its status as an Intergovernmental Organization        *
0009 * or submit itself to any jurisdiction.                                             *
0010 \***********************************************************************************/
0011 #ifndef GAUDIUTILS_IIODATAMANAGER_H
0012 #define GAUDIUTILS_IIODATAMANAGER_H
0013 
0014 // Framework include files
0015 #include "GaudiKernel/IInterface.h"
0016 
0017 // C++ include files
0018 #include <string>
0019 #include <vector>
0020 
0021 /*
0022  *  LHCb namespace declaration
0023  */
0024 namespace Gaudi {
0025 
0026   /** @class IDataConnection
0027    *
0028    *  ABC describing basic data connection
0029    *
0030    *  @author  M.Frank
0031    *  @version 1.0
0032    *  @date    20/10/2007
0033    */
0034   class GAUDI_API IDataConnection {
0035   protected:
0036     /// Connection name/identifier
0037     std::string m_name;
0038     /// File ID of the connection
0039     std::string m_fid;
0040     /// Physical file name of the connection
0041     std::string m_pfn;
0042     /// Age counter
0043     int m_age = 0;
0044     /// Owner pointer
0045     const IInterface* m_owner = nullptr;
0046 
0047   public:
0048     /// I/O Connection types
0049     enum IoType { READ = 1 << 1, UPDATE = 1 << 2, CREATE = 1 << 3, RECREATE = ( 1 << 4 ) + ( 1 << 3 ) };
0050     /// Status Code on bad file connection
0051     enum IoStatus { BAD_DATA_CONNECTION = 4 };
0052 
0053   public:
0054     /// Standard constructor
0055     IDataConnection( const IInterface* own, std::string nam ) : m_name( std::move( nam ) ), m_owner( own ) {}
0056     /// Standard destructor
0057     virtual ~IDataConnection() = default;
0058     /// Connection name
0059     const std::string& name() const { return m_name; }
0060     /// Set file ID
0061     void setFID( std::string fid ) { m_fid = std::move( fid ); }
0062     /// Access file id
0063     const std::string& fid() const { return m_fid; }
0064     /// Access physical file name
0065     const std::string& pfn() const { return m_pfn; }
0066     /// Set physical file name
0067     void setPFN( std::string fn ) { m_pfn = std::move( fn ); }
0068     /// Increase age of I/O source
0069     int ageFile() { return ++m_age; }
0070     /// Reset age
0071     void resetAge() { m_age = 0; }
0072     /// Access age counter
0073     int age() const { return m_age; }
0074     /// Owner instance
0075     const IInterface* owner() const { return m_owner; }
0076     /// Open data stream in read mode
0077     virtual StatusCode connectRead() = 0;
0078     /// Open data stream in write mode
0079     virtual StatusCode connectWrite( IoType type ) = 0;
0080     /// Release data stream
0081     virtual StatusCode disconnect() = 0;
0082     /// Check if connected to data source
0083     virtual bool isConnected() const = 0;
0084     /// Read raw byte buffer from input stream
0085     virtual StatusCode read( void* const data, size_t len ) = 0;
0086     /// Write raw byte buffer to output stream
0087     virtual StatusCode write( const void* data, int len ) = 0;
0088     /// Seek on the file described by ioDesc. Arguments as in ::seek()
0089     virtual long long int seek( long long int where, int origin ) = 0;
0090   };
0091 
0092   /** @class IIODataManager
0093    *
0094    *  @author  M.Frank
0095    *  @version 1.0
0096    *  @date    20/10/2007
0097    */
0098   class GAUDI_API IIODataManager : virtual public IInterface {
0099   public:
0100     /// InterfaceID
0101     DeclareInterfaceID( IIODataManager, 2, 0 );
0102 
0103     /// Connection type definition
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     /// Open data stream in read mode
0110     virtual StatusCode connectRead( bool keep_open, IDataConnection* con ) = 0;
0111     /// Open data stream in write mode
0112     virtual StatusCode connectWrite( IDataConnection* con, IoType mode = Connection::CREATE,
0113                                      const std::string& doctype = "UNKNOWN" ) = 0;
0114     /// Release data stream
0115     virtual StatusCode disconnect( IDataConnection* con ) = 0;
0116     /// Retrieve known connection
0117     virtual Connection* connection( const std::string& dsn ) const = 0;
0118     /// Get connection by owner instance (0=ALL)
0119     virtual Connections connections( const IInterface* owner ) const = 0;
0120     /// Read raw byte buffer from input stream
0121     virtual StatusCode read( IDataConnection* con, void* const data, size_t len ) = 0;
0122     /// Write raw byte buffer to output stream
0123     virtual StatusCode write( IDataConnection* con, const void* data, int len ) = 0;
0124     /// Seek on the file described by ioDesc. Arguments as in ::seek()
0125     virtual long long int seek( IDataConnection* con, long long int where, int origin ) = 0;
0126   };
0127 } // End namespace Gaudi
0128 #endif // GAUDIUTILS_IIODATAMANAGER_H