ATLAS Offline Software
ToolHandleArray.icc
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef ASGTOOLS_TOOLHANDLEARRAY_ICC
6 #define ASGTOOLS_TOOLHANDLEARRAY_ICC
7 
8 template< class T >
9 ToolHandleArray< T >::ToolHandleArray()
10  : std::vector< ToolHandle< T > >() {
11 
12 }
13 
14 template< class T >
15 ToolHandleArray< T >::
16 ToolHandleArray( const std::initializer_list< ToolHandle< T > >& l )
17  : std::vector< ToolHandle< T > >( l ) {
18 
19 }
20 
21 template< class T >
22 ToolHandleArray< T >::
23 ToolHandleArray( const std::initializer_list< std::string >& l )
24  : std::vector< ToolHandle< T > >() {
25 
26  // Create ToolHandle objects from all the names:
27  for( auto name : l ) {
28  this->push_back( ToolHandle< T >( name ) );
29  }
30 }
31 
32 template< class T > template< typename Parent >
33 ToolHandleArray< T >::
34 ToolHandleArray( Parent *parent, const std::string& name, const std::initializer_list< std::string >& l, const std::string& description )
35  : ToolHandleArray (l) {
36 
37  parent->declareProperty (name, *this, description);
38 }
39 
40 template< class T >
41 StatusCode ToolHandleArray< T >::retrieve() const {
42 
43  // Loop over all the elements:
44  typename ToolHandleArray< T >::const_iterator itr = this->begin();
45  typename ToolHandleArray< T >::const_iterator end = this->end();
46  for( ; itr != end; ++itr ) {
47  if( itr->retrieve().isFailure() ) {
48  return StatusCode::FAILURE;
49  }
50  }
51 
52  // Return gracefully:
53  return StatusCode::SUCCESS;
54 }
55 
56 namespace asg
57 {
58  namespace detail
59  {
60  template<typename T> struct GetStringHelper;
61 
62  template<typename T> struct GetStringHelper<ToolHandleArray<T> >
63  : public GetStringHelper<std::vector<ToolHandle<T> > >
64  {
65  };
66 
67  template<typename T> struct SetStringHelper;
68 
69  template<typename T> struct SetStringHelper<ToolHandleArray<T> >
70  : public SetStringHelper<std::vector<ToolHandle<T> > >
71  {
72  };
73  }
74 }
75 
76 #endif // ASGTOOLS_TOOLHANDLEARRAY_ICC