The Gaudi Framework  master (594c33fa)
FileMgrTest Class Reference

an algorithm to test the FileMgr More...

#include </builds/gaudi/Gaudi/GaudiTestSuite/src/FileMgr/FileMgrTest.h>

Inheritance diagram for FileMgrTest:
Collaboration diagram for FileMgrTest:

Public Member Functions

 FileMgrTest (const std::string &name, ISvcLocator *pSvcLocator)
 
StatusCode initialize () override
 
StatusCode execute () override
 
StatusCode finalize () override
 
- Public Member Functions inherited from Gaudi::details::LegacyAlgorithmAdapter
 LegacyAlgorithmAdapter (std::string name, ISvcLocator *svcloc, std::string version=PACKAGE_VERSION)
 
const EventContextgetContext () const
 
bool isExecuted () const
 Has this algorithm been executed since the last reset? More...
 
void setExecuted (bool state) const
 Set the executed flag to the specified state. More...
 
bool filterPassed () const
 Did this algorithm pass or fail its filter criterion for the last event? More...
 
void setFilterPassed (bool state) const
 Set the filter passed flag to the specified state. More...
 
- Public Member Functions inherited from Gaudi::Algorithm
 Algorithm (std::string name, ISvcLocator *svcloc, std::string version=PACKAGE_VERSION)
 Constructor. More...
 
StatusCode sysStart () override
 Reinitialization method invoked by the framework. More...
 
StatusCode sysInitialize () override
 Initialization method invoked by the framework. More...
 
StatusCode sysReinitialize () override
 Reinitialization method invoked by the framework. More...
 
StatusCode sysRestart () override
 Restart method invoked by the framework. More...
 
StatusCode sysExecute (const EventContext &ctx) override
 The actions to be performed by the algorithm on an event. More...
 
StatusCode sysStop () override
 System stop. More...
 
StatusCode sysFinalize () override
 System finalization. More...
 
const std::stringname () const override
 The identifying name of the algorithm object. More...
 
const Gaudi::StringKeynameKey () const override
 
const std::stringtype () const override
 The type of the algorithm object. More...
 
void setType (std::string type) override
 
const std::stringversion () const override
 
unsigned int index () const override
 
StatusCode configure () override
 Dummy implementation of IStateful::configure() method. More...
 
StatusCode terminate () override
 Dummy implementation of IStateful::terminate() method. More...
 
StatusCode initialize () override
 the default (empty) implementation of IStateful::initialize() method More...
 
StatusCode start () override
 the default (empty) implementation of IStateful::start() method More...
 
StatusCode stop () override
 the default (empty) implementation of IStateful::stop() method More...
 
StatusCode finalize () override
 the default (empty) implementation of IStateful::finalize() method More...
 
StatusCode reinitialize () override
 the default (empty) implementation of IStateful::reinitialize() method More...
 
StatusCode restart () override
 the default (empty) implementation of IStateful::restart() method More...
 
Gaudi::StateMachine::State FSMState () const override
 returns the current state of the algorithm More...
 
Gaudi::StateMachine::State targetFSMState () const override
 returns the state the algorithm will be in after the ongoing transition More...
 
bool isEnabled () const override
 Is this algorithm enabled or disabled? More...
 
bool isSequence () const override
 Are we a Sequence? More...
 
unsigned int errorCount () const
 Get the number of failures of the algorithm. More...
 
template<class T >
StatusCode service (std::string_view name, T *&psvc, bool createIf=true) const
 Access a service by name, creating it if it doesn't already exist. More...
 
template<class T >
StatusCode service (std::string_view svcType, std::string_view svcName, T *&psvc) const
 Access a service by name and type, creating it if it doesn't already exist. More...
 
SmartIF< IServiceservice (std::string_view name, const bool createIf=true, const bool quiet=false) const
 Return a pointer to the service identified by name (or "type/name") More...
 
template<class T >
SmartIF< T > service (std::string_view name, bool createIf=true, bool quiet=false) const
 
SmartIF< IAuditorSvc > & auditorSvc () const
 The standard auditor service.May not be invoked before sysInitialize() has been invoked. More...
 
SmartIF< IChronoStatSvc > & chronoSvc () const
 The standard Chrono & Stat service, Return a pointer to the service if present. More...
 
SmartIF< IDataProviderSvc > & detSvc () const
 The standard detector data service. More...
 
SmartIF< IConversionSvc > & detCnvSvc () const
 The standard detector data persistency conversion service. More...
 
SmartIF< IDataProviderSvc > & eventSvc () const
 The standard event data service. More...
 
SmartIF< IDataProviderSvc > & evtSvc () const
 shortcut for method eventSvc More...
 
SmartIF< IConversionSvc > & eventCnvSvc () const
 The standard event data persistency conversion service. More...
 
SmartIF< IHistogramSvc > & histoSvc () const
 The standard histogram service. More...
 
SmartIF< INTupleSvc > & ntupleSvc () const
 The standard N tuple service. More...
 
SmartIF< IRndmGenSvc > & randSvc () const
 The standard RandomGen service, Return a pointer to the service if present. More...
 
SmartIF< IToolSvc > & toolSvc () const
 The standard ToolSvc service, Return a pointer to the service if present. More...
 
SmartIF< IExceptionSvc > & exceptionSvc () const
 Get the exception Service. More...
 
SmartIF< IAlgContextSvc > & contextSvc () const
 get Algorithm Context Service More...
 
SmartIF< ITimelineSvc > & timelineSvc () const
 
SmartIF< ISvcLocator > & serviceLocator () const override
 The standard service locator. More...
 
SmartIF< ISvcLocator > & svcLoc () const
 shortcut for method serviceLocator More...
 
SmartIF< IHiveWhiteBoard > & whiteboard () const
 
SmartIF< IAlgExecStateSvc > & algExecStateSvc () const
 
bool registerContext () const
 register for Algorithm Context Service? More...
 
template<class T >
Gaudi::Details::PropertyBasedeclareProperty (const std::string &name, ToolHandle< T > &hndl, const std::string &doc="none")
 
template<class T >
Gaudi::Details::PropertyBasedeclareProperty (const std::string &name, ToolHandleArray< T > &hndlArr, const std::string &doc="none")
 
SmartIF< IMonitorSvc > & monitorSvc () const
 Access the monitor service. More...
 
template<class T >
void declareInfo (const std::string &name, const T &var, const std::string &desc) const
 Declare monitoring information. More...
 
void declareInfo (const std::string &name, const std::string &format, const void *var, int size, const std::string &desc) const
 Declare monitoring information (special case) More...
 
void acceptDHVisitor (IDataHandleVisitor *) const override
 
void registerTool (IAlgTool *tool) const
 
void deregisterTool (IAlgTool *tool) const
 
template<class T >
StatusCode declareTool (ToolHandle< T > &handle, bool createIf=true)
 
template<class T >
StatusCode declareTool (ToolHandle< T > &handle, std::string toolTypeAndName, bool createIf=true)
 
template<class T >
void addToolsArray (ToolHandleArray< T > &hndlArr)
 
const std::vector< IAlgTool * > & tools () const
 
bool isBlocking () const
 
void setBlocking (bool value)
 
unsigned int cardinality () const override
 Return the cardinality. More...
 
const std::vector< std::string > & neededResources () const override
 
AlgExecStateexecState (const EventContext &ctx) const override
 reference to AlgExecState of Alg More...
 
std::ostreamtoControlFlowExpression (std::ostream &os) const override
 Produce string represention of the control flow expression. More...
 
- Public Member Functions inherited from DataHandleHolderBase< PropertyHolder< CommonMessaging< implements< IAlgorithm, IDataHandleHolder, IProperty, IStateful > > > >
std::vector< Gaudi::DataHandle * > inputHandles () const override
 
std::vector< Gaudi::DataHandle * > outputHandles () const override
 
virtual const DataObjIDCollextraInputDeps () const override
 
virtual const DataObjIDCollextraOutputDeps () const override
 
void declare (Gaudi::DataHandle &handle) override
 
void renounce (Gaudi::DataHandle &handle) override
 
bool renounceInput (const DataObjID &id) override
 
const DataObjIDCollinputDataObjs () const override
 
const DataObjIDColloutputDataObjs () const override
 
void addDependency (const DataObjID &id, const Gaudi::DataHandle::Mode &mode) override
 
- Public Member Functions inherited from extends< PropertyHolder< CommonMessaging< implements< IAlgorithm, IDataHandleHolder, IProperty, IStateful > > >, IDataHandleHolder >
void * i_cast (const InterfaceID &tid) const override
 Implementation of IInterface::i_cast. More...
 
StatusCode queryInterface (const InterfaceID &ti, void **pp) override
 Implementation of IInterface::queryInterface. More...
 
std::vector< std::stringgetInterfaceNames () const override
 Implementation of IInterface::getInterfaceNames. More...
 
- Public Member Functions inherited from PropertyHolder< CommonMessaging< implements< IAlgorithm, IDataHandleHolder, IProperty, IStateful > > >
 PropertyHolder ()=default
 
Gaudi::Details::PropertyBasedeclareProperty (Gaudi::Details::PropertyBase &prop)
 Declare a property. More...
 
Gaudi::Details::PropertyBasedeclareProperty (const std::string &name, TYPE &value, const std::string &doc="none")
 Helper to wrap a regular data member and use it as a regular property. More...
 
Gaudi::Details::PropertyBasedeclareProperty (const std::string &name, Gaudi::Property< TYPE, VERIFIER, HANDLERS > &prop, const std::string &doc="none")
 Declare a PropertyBase instance setting name and documentation. More...
 
Gaudi::Details::PropertyBasedeclareRemoteProperty (const std::string &name, IProperty *rsvc, const std::string &rname="")
 Declare a remote property. More...
 
StatusCode setProperty (const std::string &name, const Gaudi::Details::PropertyBase &p) override
 set the property from another property with a different name More...
 
StatusCode setProperty (const std::string &s) override
 set the property from the formatted string More...
 
StatusCode setProperty (const Gaudi::Details::PropertyBase &p)
 Set the property from a property. More...
 
virtual StatusCode setProperty (const std::string &name, const Gaudi::Details::PropertyBase &p)=0
 Set the property from a property with a different name. More...
 
virtual StatusCode setProperty (const std::string &s)=0
 Set the property by string. More...
 
StatusCode setProperty (const std::string &name, const char *v)
 Special case for string literals. More...
 
StatusCode setProperty (const std::string &name, const std::string &v)
 Special case for std::string. More...
 
StatusCode setProperty (const std::string &name, const TYPE &value)
 set the property form the value More...
 
StatusCode setPropertyRepr (const std::string &n, const std::string &r) override
 set the property from name and value string representation More...
 
StatusCode getProperty (Gaudi::Details::PropertyBase *p) const override
 get the property More...
 
const Gaudi::Details::PropertyBasegetProperty (std::string_view name) const override
 get the property by name More...
 
StatusCode getProperty (std::string_view n, std::string &v) const override
 convert the property to the string More...
 
const std::vector< Gaudi::Details::PropertyBase * > & getProperties () const override
 get all properties More...
 
bool hasProperty (std::string_view name) const override
 Return true if we have a property with the given name. More...
 
Gaudi::Details::PropertyBaseproperty (std::string_view name) const
 \fixme property and bindPropertiesTo should be protected More...
 
void bindPropertiesTo (Gaudi::Interfaces::IOptionsSvc &optsSvc)
 
 PropertyHolder (const PropertyHolder &)=delete
 
PropertyHolderoperator= (const PropertyHolder &)=delete
 
- Public Member Functions inherited from CommonMessaging< implements< IAlgorithm, IDataHandleHolder, IProperty, IStateful > >
MSG::Level msgLevel () const
 get the cached level (originally extracted from the embedded MsgStream) More...
 
bool msgLevel (MSG::Level lvl) const
 get the output level from the embedded MsgStream More...
 

Private Member Functions

StatusCode PosixOpenAction (FILEMGR_CALLBACK_ARGS)
 
StatusCode allCloseAction (FILEMGR_CALLBACK_ARGS)
 

Private Attributes

IFileMgrp_fileMgr
 
Io::Fd fd_1 { -1 }
 
Io::Fd fd_2 { -1 }
 
Io::Fd fd_3 { -1 }
 
Io::Fd fd_4 { -1 }
 
FILE * fp_1 { nullptr }
 
FILE * fp_2 { nullptr }
 
FILE * fp_3 { nullptr }
 
FILE * fp_4 { nullptr }
 
TFile * fp_r1 { nullptr }
 
TFile * fp_r2 { nullptr }
 
TFile * fp_r3 { nullptr }
 
std::string m_f1
 
std::string m_f2
 
std::string m_f3
 
std::string m_f4
 
std::string m_fr1
 
std::string m_fr2
 
std::string m_fr3
 

Additional Inherited Members

- Public Types inherited from Gaudi::Algorithm
typedef Gaudi::PluginService::Factory< IAlgorithm *(const std::string &, ISvcLocator *)> Factory
 
- Public Types inherited from extends< PropertyHolder< CommonMessaging< implements< IAlgorithm, IDataHandleHolder, IProperty, IStateful > > >, IDataHandleHolder >
using base_class = extends
 Typedef to this class. More...
 
using extend_interfaces_base = extend_interfaces< Interfaces... >
 Typedef to the base of this class. More...
 
- Public Types inherited from PropertyHolder< CommonMessaging< implements< IAlgorithm, IDataHandleHolder, IProperty, IStateful > > >
using PropertyHolderImpl = PropertyHolder< CommonMessaging< implements< IAlgorithm, IDataHandleHolder, IProperty, IStateful > > >
 Typedef used to refer to this class from derived classes, as in. More...
 
- Public Types inherited from CommonMessaging< implements< IAlgorithm, IDataHandleHolder, IProperty, IStateful > >
using base_class = CommonMessaging
 
- Public Types inherited from extend_interfaces< Interfaces... >
using ext_iids = typename Gaudi::interface_list_cat< typename Interfaces::ext_iids... >::type
 take union of the ext_iids of all Interfaces... More...
 
- Public Attributes inherited from Gaudi::Algorithm
friend AlgorithmManager
 
- Protected Member Functions inherited from Gaudi::details::LegacyAlgorithmAdapter
bool isReEntrant () const override
 
- Protected Member Functions inherited from Gaudi::Algorithm
std::vector< IAlgTool * > & tools ()
 
bool isInitialized () const override
 Has the Algorithm already been initialized? More...
 
bool isFinalized () const override
 Has the Algorithm already been finalized? More...
 
void setIndex (const unsigned int &idx) override
 set instantiation index of Alg More...
 
bool isReEntrant () const override
 
- Protected Member Functions inherited from DataHandleHolderBase< PropertyHolder< CommonMessaging< implements< IAlgorithm, IDataHandleHolder, IProperty, IStateful > > > >
void initDataHandleHolder ()
 initializes all handles - called by the sysInitialize method of any descendant of this More...
 
- Protected Member Functions inherited from CommonMessaging< implements< IAlgorithm, IDataHandleHolder, IProperty, IStateful > >
MSG::Level setUpMessaging () const
 Set up local caches. More...
 
MSG::Level resetMessaging ()
 Reinitialize internal states. More...
 
void updateMsgStreamOutputLevel (int level)
 Update the output level of the cached MsgStream. More...
 
- Protected Attributes inherited from Gaudi::Algorithm
std::unique_ptr< IDataHandleVisitorm_updateDataHandles
 Hook for for derived classes to provide a custom visitor for data handles. More...
 
- Protected Attributes inherited from DataHandleHolderBase< PropertyHolder< CommonMessaging< implements< IAlgorithm, IDataHandleHolder, IProperty, IStateful > > > >
DataObjIDColl m_inputDataObjs
 
DataObjIDColl m_outputDataObjs
 

Detailed Description

an algorithm to test the FileMgr

Definition at line 28 of file FileMgrTest.h.

Constructor & Destructor Documentation

◆ FileMgrTest()

FileMgrTest::FileMgrTest ( const std::string name,
ISvcLocator pSvcLocator 
)

Definition at line 30 of file FileMgrTest.cpp.

31  : Algorithm( name, pSvcLocator ), p_fileMgr( 0 ) {}

Member Function Documentation

◆ allCloseAction()

StatusCode FileMgrTest::allCloseAction ( FILEMGR_CALLBACK_ARGS  )
private

Definition at line 304 of file FileMgrTest.cpp.

304  {
305 
306  info() << "AllCloseAction called by " << c << " for tech " << fa->tech() << " on " << fa << endmsg;
307 
308  return StatusCode::SUCCESS;
309 }

◆ execute()

StatusCode FileMgrTest::execute ( )
overridevirtual

Implements Algorithm.

Definition at line 178 of file FileMgrTest.cpp.

178  {
179 
180 #ifndef __APPLE__
181  info() << "writing to " << p_fileMgr->fname( (void*)fp_2 ) << endmsg;
182 
183  std::ofstream ofs;
184  __gnu_cxx::stdio_filebuf<char> fb( fp_2, std::ios::out );
185 
186  ofs.std::ios::rdbuf( &fb );
187  ofs << "Hello World!" << std::endl;
188 
189  info() << "appending to " << p_fileMgr->fname( (void*)fp_3 ) << endmsg;
190 
191  std::ofstream ofs2;
192  __gnu_cxx::stdio_filebuf<char> fb2( fp_3, std::ios::out );
193 
194  ofs2.std::ios::rdbuf( &fb2 );
195  ofs2 << "Hello World!" << std::endl;
196 #endif // not __APPLE__
197 
198  return StatusCode::SUCCESS;
199 }

◆ finalize()

StatusCode FileMgrTest::finalize ( )
override

Definition at line 203 of file FileMgrTest.cpp.

203  {
204 
207  int i = p_fileMgr->getFiles( v );
208 
209  auto& log = info();
210  log << "listing all open files [" << i << "]" << std::endl;
211  for ( itr = v.begin(); itr != v.end(); ++itr ) { log << " " << *itr << std::endl; }
212  log << endmsg;
213 
214  i = p_fileMgr->getFiles( v, false );
215  log << "listing ALL files [" << i << "]" << std::endl;
216  for ( itr = v.begin(); itr != v.end(); ++itr ) { log << " " << *itr << std::endl; }
217  log << endmsg;
218 
221  i = p_fileMgr->getFiles( Io::POSIX, v2, false );
222  log << "listing all POSIX files ever opened [" << i << "]" << std::endl;
223  for ( it2 = v2.begin(); it2 != v2.end(); ++it2 ) { log << " " << ( *it2 )->name() << std::endl; }
224  log << endmsg;
225 
226  int r;
227 
228  r = p_fileMgr->close( fd_1, name() );
229  if ( r != 0 ) {
230  error() << "unable to close " << m_f1 << " with FD " << fd_1 << endmsg;
231  } else {
232  info() << "closed " << m_f1 << endmsg;
233  }
234 
235  r = p_fileMgr->close( fd_2, name() );
236  if ( r != 0 ) {
237  error() << "unable to close " << m_f2 << " with FD " << fd_2 << endmsg;
238  } else {
239  info() << "closed " << m_f2 << endmsg;
240  }
241 
242  r = p_fileMgr->close( fd_3, name() );
243  if ( r != 0 ) {
244  error() << "unable to close " << m_f3 << " with FD " << fd_3 << endmsg;
245  } else {
246  info() << "closed " << m_f3 << endmsg;
247  }
248 
249  r = p_fileMgr->close( fd_4, name() );
250  if ( r != 0 ) {
251  error() << "unable to close " << m_f1 << " with FD " << fd_4 << endmsg;
252  } else {
253  info() << "closed " << m_f1 << endmsg;
254  }
255 
256  r = p_fileMgr->close( fp_r1, name() );
257  if ( r != 0 ) {
258  error() << "unable to close " << m_fr1 << " with ptr " << fp_r1 << endmsg;
259  } else {
260  info() << "closed " << m_fr1 << endmsg;
261  }
262 
263  r = p_fileMgr->close( fp_r2, name() );
264  if ( r != 0 ) {
265  error() << "unable to close " << m_fr2 << " with ptr " << fp_r2 << endmsg;
266  } else {
267  info() << "closed " << m_fr2 << endmsg;
268  }
269 
270  // r = p_fileMgr->close(fp_r3,name());
271  // if (r != 0) {
272  // error() << "unable to close " << m_fr3 << " with ptr " << fp_r3
273  // << endmsg;
274  // } else {
275  // info() << "closed " << m_fr3 << endmsg;
276  // }
277 
278  return StatusCode::SUCCESS;
279 }

◆ initialize()

StatusCode FileMgrTest::initialize ( )
override

Definition at line 35 of file FileMgrTest.cpp.

35  {
36 
38 
39  m_f1 = "/etc/redhat-release";
40  m_f2 = "t2.txt";
41  m_f3 = "t3.txt";
42  m_f4 = "t4.txt";
43 
44  m_fr1 = "tuple1.rt";
45  m_fr2 = "http://annwm.lbl.gov/~leggett/tuple2.rt";
46  m_fr3 = "https://t-dpm.grid.sinica.edu.tw/dpm/grid.sinica.edu.tw/home/atlas/atlasppsscratchdisk/mc10_7TeV/AOD/"
47  "e574_s1110_s1100_r1655_r1700/"
48  "mc10_7TeV.105805.filtered_minbias6.merge.AOD.e574_s1110_s1100_r1655_r1700_tid261524_00/"
49  "AOD.261524._032551.pool.root.1";
50 
51  if ( service( "FileMgr", p_fileMgr, true ).isFailure() ) {
52  error() << "unable to get the FileMgr" << endmsg;
54  } else {
55  debug() << "got the FileMgr" << endmsg;
56  }
57 
58  Io::bfcn_action_t boa =
59  std::bind( &FileMgrTest::PosixOpenAction, this, std::placeholders::_1, std::placeholders::_2 );
60  if ( p_fileMgr->regAction( boa, Io::OPEN, Io::POSIX, "FileMgrTest::POSIXOpenAction" ).isFailure() ) {
61  error() << "unable to register POSIX file open action with FileMgr" << endmsg;
62  }
63 
64  if ( p_fileMgr->regAction( boa, Io::OPEN_ERR, Io::POSIX, "FileMgrTest::PosixOpenAction" ).isFailure() ) {
65  error() << "unable to register POSIX file open ERR action with FileMgr" << endmsg;
66  }
67 
68  Io::bfcn_action_t bob = std::bind( &FileMgrTest::allCloseAction, this, std::placeholders::_1, std::placeholders::_2 );
69  if ( p_fileMgr->regAction( bob, Io::CLOSE ).isFailure() ) {
70  // "FileMgrTest::allCloseAction").isFailure()) {
71  error() << "unable to register all Close action with FileMgr" << endmsg;
72  }
73 
74  int r;
75 
76  r = p_fileMgr->open( Io::POSIX, name(), m_f1, Io::READ, fd_1, "ASCII" );
77  if ( r != 0 ) {
78  error() << "unable to open " << m_f1 << " for reading" << endmsg;
79  } else {
80  // fp_1 = fdopen(fd_1, "r");
81  fp_1 = (FILE*)p_fileMgr->fptr( fd_1 );
82  info() << "opened " << m_f1 << " for reading with FD: " << fd_1 << " FILE* " << fp_1 << endmsg;
83  }
84 
85  r = p_fileMgr->open( Io::POSIX, name(), m_f2, Io::WRITE | Io::CREATE, fd_2, "ASCII" );
86  if ( r != 0 ) {
87  error() << "unable to open " << m_f2 << " for writing" << endmsg;
88  } else {
89  // fp_2 = fdopen(fd_2,"w");
90  fp_2 = (FILE*)p_fileMgr->fptr( fd_2 );
91  info() << "opened " << m_f2 << " for writing with FD: " << fd_2 << " FILE* " << fp_2 << endmsg;
92  }
93 
94  // make sure we have something in m_f3 to append to;
95  std::ofstream ofs{ m_f3 };
96  ofs << "initial line" << std::endl;
97  ofs.close();
98 
99  r = p_fileMgr->open( Io::POSIX, name(), m_f3, Io::WRITE | Io::APPEND, fd_3, "ASCII" );
100  if ( r != 0 ) {
101  error() << "unable to open " << m_f3 << " for write|append" << endmsg;
102  } else {
103  // fp_3 = fdopen(fd_3,"a");
104  fp_3 = (FILE*)p_fileMgr->fptr( fd_3 );
105  info() << "opened " << m_f3 << " for reading with FD: " << fd_3 << " FILE* " << fp_3 << endmsg;
106  }
107 
108  Io::Fd fd;
109 
110  error() << "the following error is expected" << endmsg;
111  r = p_fileMgr->open( Io::POSIX, name(), m_f2, Io::WRITE | Io::CREATE | Io::EXCL, fd, "ASCII" );
112  if ( r != 0 ) {
113  info() << "unable to open " << m_f2 << " for WRITE|CREATE|EXCL - expected as file already exists" << endmsg;
114  } else {
115  error() << "opened " << m_f2 << " for reading with FD: " << fd << " This should not occur!" << endmsg;
116  }
117 
118  r = p_fileMgr->open( Io::POSIX, name(), m_f1, Io::READ, fd_4, "ASCII" );
119  if ( r != 0 ) {
120  error() << "unable to open " << m_f1 << " again for reading" << endmsg;
121  } else {
122  fp_4 = (FILE*)p_fileMgr->fptr( fd_4 );
123  info() << "opened " << m_f1 << " again for reading with FD: " << fd_4 << " FILE* " << fp_4 << endmsg;
124  }
125 
126  void* vp( 0 );
127  r = p_fileMgr->open( Io::ROOT, name(), m_fr1, Io::READ, vp, "HIST" );
128  if ( r != 0 ) {
129  error() << "unable to open " << m_fr1 << " again for reading" << endmsg;
130  } else {
131  fp_r1 = (TFile*)vp;
132  info() << "opened " << m_fr1 << " for reading with ptr: " << fp_r1 << endmsg;
133  }
134 
135  r = p_fileMgr->open( Io::ROOT, name(), m_fr2, Io::READ, vp, "HIST" );
136  if ( r != 0 ) {
137  error() << "unable to open " << m_fr2 << " for reading" << endmsg;
138  } else {
139  fp_r2 = (TFile*)vp;
140  info() << "opened " << m_fr2 << " for reading with ptr: " << fp_r2 << " size: " << fp_r2->GetSize() << endmsg;
141  }
142 
143  // std::string cafile, capath,ucert,ukey;
144  // cafile = "/tmp/x509up_u6919";
145  // capath = "/afs/cern.ch/project/gd/LCG-share2/certificates";
146  // ucert = cafile;
147  // ukey = cafile;
148 
149  // TSSLSocket::SetUpSSL(cafile.c_str(), capath.c_str(), ucert.c_str(), ukey.c_str());
150  r = p_fileMgr->open( Io::ROOT, name(), m_fr3, Io::READ, vp, "HIST" );
151  if ( r != 0 ) {
152  error() << "unable to open " << m_fr3 << " for reading" << endmsg;
153  } else {
154  fp_r3 = (TFile*)vp;
155  info() << "opened " << m_fr3 << " for reading with ptr: " << fp_r3 << " size: " << fp_r3->GetSize() << endmsg;
156  }
157 
158  for ( int j = 0; j < 2; ++j ) {
159  r = p_fileMgr->open( Io::POSIX, name(), "t6.txt", Io::WRITE | Io::CREATE, fd, "ASCII" );
160  if ( r != 0 ) {
161  error() << "unable to open t6.txt for writing" << endmsg;
162  } else {
163  info() << "opened t6.txt for writing, fd: " << fd << " will now close" << endmsg;
164  r = p_fileMgr->close( fd, name() );
165  if ( r != 0 ) {
166  error() << "unable to close " << m_f1 << " with FD " << fd_1 << endmsg;
167  } else {
168  info() << "closed " << name() << endmsg;
169  }
170  }
171  }
172 
173  return st;
174 }

◆ PosixOpenAction()

StatusCode FileMgrTest::PosixOpenAction ( FILEMGR_CALLBACK_ARGS  )
private

Definition at line 283 of file FileMgrTest.cpp.

283  {
284 
285  info() << "PosixOpenAction called by " << c << " for tech " << fa->tech() << " on " << fa << endmsg;
286 
287  // if (fa.tech() != Io::POSIX) {
288 
289  // // error() << "PosixOpenAction called for incorrect tech: "
290  // // << fa.tech() << " on " << fa
291  // // << endmsg;
292 
293  // return StatusCode::SUCCESS;
294  // }
295 
296  // info() << "PosixOpenAction for " << fa
297  // << endmsg;
298 
299  return StatusCode::SUCCESS;
300 }

Member Data Documentation

◆ fd_1

Io::Fd FileMgrTest::fd_1 { -1 }
private

Definition at line 38 of file FileMgrTest.h.

◆ fd_2

Io::Fd FileMgrTest::fd_2 { -1 }
private

Definition at line 38 of file FileMgrTest.h.

◆ fd_3

Io::Fd FileMgrTest::fd_3 { -1 }
private

Definition at line 38 of file FileMgrTest.h.

◆ fd_4

Io::Fd FileMgrTest::fd_4 { -1 }
private

Definition at line 38 of file FileMgrTest.h.

◆ fp_1

FILE* FileMgrTest::fp_1 { nullptr }
private

Definition at line 39 of file FileMgrTest.h.

◆ fp_2

FILE * FileMgrTest::fp_2 { nullptr }
private

Definition at line 39 of file FileMgrTest.h.

◆ fp_3

FILE * FileMgrTest::fp_3 { nullptr }
private

Definition at line 39 of file FileMgrTest.h.

◆ fp_4

FILE * FileMgrTest::fp_4 { nullptr }
private

Definition at line 39 of file FileMgrTest.h.

◆ fp_r1

TFile* FileMgrTest::fp_r1 { nullptr }
private

Definition at line 40 of file FileMgrTest.h.

◆ fp_r2

TFile * FileMgrTest::fp_r2 { nullptr }
private

Definition at line 40 of file FileMgrTest.h.

◆ fp_r3

TFile * FileMgrTest::fp_r3 { nullptr }
private

Definition at line 40 of file FileMgrTest.h.

◆ m_f1

std::string FileMgrTest::m_f1
private

Definition at line 41 of file FileMgrTest.h.

◆ m_f2

std::string FileMgrTest::m_f2
private

Definition at line 41 of file FileMgrTest.h.

◆ m_f3

std::string FileMgrTest::m_f3
private

Definition at line 41 of file FileMgrTest.h.

◆ m_f4

std::string FileMgrTest::m_f4
private

Definition at line 41 of file FileMgrTest.h.

◆ m_fr1

std::string FileMgrTest::m_fr1
private

Definition at line 41 of file FileMgrTest.h.

◆ m_fr2

std::string FileMgrTest::m_fr2
private

Definition at line 41 of file FileMgrTest.h.

◆ m_fr3

std::string FileMgrTest::m_fr3
private

Definition at line 41 of file FileMgrTest.h.

◆ p_fileMgr

IFileMgr* FileMgrTest::p_fileMgr
private

Definition at line 37 of file FileMgrTest.h.


The documentation for this class was generated from the following files:
IFileMgr::getFiles
virtual int getFiles(std::vector< std::string > &FILES, bool onlyOpen=true) const =0
FileMgrTest::fp_2
FILE * fp_2
Definition: FileMgrTest.h:39
Io::OPEN
@ OPEN
Definition: IFileMgr.h:278
FileMgrTest::fp_4
FILE * fp_4
Definition: FileMgrTest.h:39
Io::CLOSE
@ CLOSE
Definition: IFileMgr.h:278
std::bind
T bind(T... args)
FileMgrTest::fd_4
Io::Fd fd_4
Definition: FileMgrTest.h:38
FileMgrTest::fp_r1
TFile * fp_r1
Definition: FileMgrTest.h:40
Gaudi.Configuration.log
log
Definition: Configuration.py:28
FileMgrTest::fd_1
Io::Fd fd_1
Definition: FileMgrTest.h:38
FileMgrTest::m_f3
std::string m_f3
Definition: FileMgrTest.h:41
Gaudi::Algorithm::name
const std::string & name() const override
The identifying name of the algorithm object.
Definition: Algorithm.cpp:528
gaudirun.fd
fd
Definition: gaudirun.py:628
std::vector< std::string >
Io::READ
@ READ
Definition: IFileMgr.h:37
Io::WRITE
@ WRITE
Definition: IFileMgr.h:38
gaudirun.c
c
Definition: gaudirun.py:525
std::function
FileMgrTest::fp_3
FILE * fp_3
Definition: FileMgrTest.h:39
FileMgrTest::m_fr1
std::string m_fr1
Definition: FileMgrTest.h:41
StatusCode
Definition: StatusCode.h:65
IFileMgr::regAction
virtual StatusCode regAction(Io::bfcn_action_t, const Io::Action &, const std::string &d="")=0
Io::ROOT
@ ROOT
Definition: IFileMgr.h:156
ProduceConsume.j
j
Definition: ProduceConsume.py:101
std::ofstream
STL class.
FileMgrTest::fp_r2
TFile * fp_r2
Definition: FileMgrTest.h:40
FileMgrTest::fp_1
FILE * fp_1
Definition: FileMgrTest.h:39
GaudiPartProp.tests.v2
v2
Definition: tests.py:59
Io::EXCL
@ EXCL
Definition: IFileMgr.h:42
FileMgrTest::allCloseAction
StatusCode allCloseAction(FILEMGR_CALLBACK_ARGS)
Definition: FileMgrTest.cpp:304
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:203
Io::Fd
int Fd
Definition: IFileMgr.h:169
FileMgrTest::fd_2
Io::Fd fd_2
Definition: FileMgrTest.h:38
IFileMgr::fname
virtual const std::string & fname(const Io::Fd &) const =0
StatusCode::isFailure
bool isFailure() const
Definition: StatusCode.h:129
FileMgrTest::m_fr3
std::string m_fr3
Definition: FileMgrTest.h:41
FileMgrTest::m_f1
std::string m_f1
Definition: FileMgrTest.h:41
StatusCode::SUCCESS
constexpr static const auto SUCCESS
Definition: StatusCode.h:100
std::endl
T endl(T... args)
FileMgrTest::PosixOpenAction
StatusCode PosixOpenAction(FILEMGR_CALLBACK_ARGS)
Definition: FileMgrTest.cpp:283
Gaudi::Algorithm::service
StatusCode service(std::string_view name, T *&psvc, bool createIf=true) const
Access a service by name, creating it if it doesn't already exist.
Definition: Algorithm.h:205
FileMgrTest::p_fileMgr
IFileMgr * p_fileMgr
Definition: FileMgrTest.h:37
FileMgrTest::m_f4
std::string m_f4
Definition: FileMgrTest.h:41
FileMgrTest::fd_3
Io::Fd fd_3
Definition: FileMgrTest.h:38
Io::OPEN_ERR
@ OPEN_ERR
Definition: IFileMgr.h:278
Properties.v
v
Definition: Properties.py:122
Io::POSIX
@ POSIX
Definition: IFileMgr.h:156
IFileMgr::close
virtual Io::close_t close(const Io::Fd, const std::string &caller)=0
Gaudi::Algorithm::Algorithm
Algorithm(std::string name, ISvcLocator *svcloc, std::string version=PACKAGE_VERSION)
Constructor.
Definition: Algorithm.h:101
StatusCode::FAILURE
constexpr static const auto FAILURE
Definition: StatusCode.h:101
IFileMgr::open
virtual Io::open_t open(const Io::IoTech &, const std::string &caller, const std::string &fname, const Io::IoFlags &, Io::Fd &, void *&, const std::string &desc, const bool shared=false)=0
FileMgrTest::m_fr2
std::string m_fr2
Definition: FileMgrTest.h:41
FileMgrTest::fp_r3
TFile * fp_r3
Definition: FileMgrTest.h:40
Io::APPEND
@ APPEND
Definition: IFileMgr.h:45
FileMgrTest::m_f2
std::string m_f2
Definition: FileMgrTest.h:41
IFileMgr::fptr
virtual void * fptr(const std::string &) const =0
PrepareBase.out
out
Definition: PrepareBase.py:20
Io::CREATE
@ CREATE
Definition: IFileMgr.h:41