Loading [MathJax]/jax/output/HTML-CSS/config.js
The Gaudi Framework  v38r1p1 (ae26267b)
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
StringKeyEx.cpp
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 // ===========================================================================
12 // Include files
13 // ===========================================================================
14 // STD & STL
15 // ===========================================================================
16 #include <map>
17 // ===========================================================================
18 // GaudiKernel
19 // ===========================================================================
20 #include "GaudiKernel/HashMap.h"
21 #include "GaudiKernel/Map.h"
22 #include "GaudiKernel/StatusCode.h"
23 #include "GaudiKernel/StringKey.h"
24 // ===========================================================================
25 // GaudiAlg
26 // ===========================================================================
28 // ===========================================================================
29 namespace Gaudi {
30  // =========================================================================
31  namespace TestSuite {
32  // =======================================================================
39  class StringKeyEx : public TestAlg {
40  public:
41  // ======================================================================
43  StatusCode execute() override;
44  // ======================================================================
45  public:
46  // ======================================================================
48  using TestAlg::TestAlg;
49  // ======================================================================
50  private:
51  // ======================================================================
54  // ======================================================================
55  Gaudi::Property<Key> m_key{ this, "Key", {}, "The string key" };
56  Gaudi::Property<Keys> m_keys{ this, "Keys", {}, "The vector of keys" };
57  // ======================================================================
58  };
59  // ========================================================================
60  } // namespace TestSuite
61  // ==========================================================================
62 } // end of namespace Gaudi
63 // ============================================================================
64 // Execution method
65 // ============================================================================
67  // 1. check the settings of key from the properties
68  always() << "The Key : " << Gaudi::Utils::toString( m_key.value() ) << endmsg;
69  always() << "The Keys : " << Gaudi::Utils::toString( m_keys.value() ) << endmsg;
70  //
71 
72  // prepare some maps
73  typedef std::map<std::string, int> MAP1;
77 
78  typedef std::map<Key, int> MAP01;
79  typedef GaudiUtils::Map<Key, int> MAP02;
80  typedef GaudiUtils::HashMap<Key, int> MAP03;
81  typedef GaudiUtils::VectorMap<Key, int> MAP04;
82 
83  MAP1 map1;
84  MAP2 map2;
85  MAP3 map3;
86  MAP4 map4;
87 
88  MAP01 map01;
89  MAP02 map02;
90  MAP03 map03;
91  MAP04 map04;
92 
93  for ( Keys::const_iterator it = m_keys.begin(); m_keys.end() != it; ++it ) {
94  int index = it - m_keys.begin();
95 
96  map1.insert( std::make_pair( *it, index ) );
97  map2.insert( std::make_pair( *it, index ) );
98  map3.insert( std::make_pair( *it, index ) );
99  map4.insert( std::make_pair( *it, index ) );
100 
101  map01.insert( std::make_pair( *it, index ) );
102  map02.insert( std::make_pair( *it, index ) );
103  map03.insert( std::make_pair( *it, index ) );
104  map04.insert( std::make_pair( *it, index ) );
105  }
106 
107  always() << "Map 1:" << Gaudi::Utils::toString( map1 ) << endmsg;
108  always() << "Map 2:" << Gaudi::Utils::toString( map2 ) << endmsg;
109  always() << "Map 3:" << Gaudi::Utils::toString( map3 ) << endmsg;
110  always() << "Map 4:" << Gaudi::Utils::toString( map4 ) << endmsg;
111 
112  always() << "Map01:" << Gaudi::Utils::toString( map01 ) << endmsg;
113  always() << "Map02:" << Gaudi::Utils::toString( map02 ) << endmsg;
114  always() << "Map03:" << Gaudi::Utils::toString( map03 ) << endmsg;
115  always() << "Map04:" << Gaudi::Utils::toString( map04 ) << endmsg;
116 
117  always() << "check for StringKey " << Gaudi::Utils::toString( m_key.value() ) << endmsg;
118 
119  always() << " In Map 1: " << Gaudi::Utils::toString( map1.end() != map1.find( m_key.value() ) ) << endmsg;
120  always() << " In Map 2: " << Gaudi::Utils::toString( map2.end() != map2.find( m_key.value() ) ) << endmsg;
121  always() << " In Map 3: " << Gaudi::Utils::toString( map3.end() != map3.find( m_key.value() ) ) << endmsg;
122  always() << " In Map 4: " << Gaudi::Utils::toString( map4.end() != map4.find( m_key.value() ) ) << endmsg;
123 
124  always() << " In Map01: " << Gaudi::Utils::toString( map01.end() != map01.find( m_key ) ) << endmsg;
125  always() << " In Map02: " << Gaudi::Utils::toString( map02.end() != map02.find( m_key ) ) << endmsg;
126  always() << " In Map03: " << Gaudi::Utils::toString( map03.end() != map03.find( m_key ) ) << endmsg;
127  always() << " In Map04: " << Gaudi::Utils::toString( map04.end() != map04.find( m_key ) ) << endmsg;
128 
129  std::string akey = "rrr";
130 
131  always() << "check for std::string key " << Gaudi::Utils::toString( akey ) << endmsg;
132 
133  always() << " In Map 1: " << Gaudi::Utils::toString( map1.end() != map1.find( akey ) ) << endmsg;
134  always() << " In Map 2: " << Gaudi::Utils::toString( map2.end() != map2.find( akey ) ) << endmsg;
135  always() << " In Map 3: " << Gaudi::Utils::toString( map3.end() != map3.find( akey ) ) << endmsg;
136  always() << " In Map 4: " << Gaudi::Utils::toString( map4.end() != map4.find( akey ) ) << endmsg;
137 
138  always() << " In Map01: " << Gaudi::Utils::toString( map01.end() != map01.find( akey ) ) << endmsg;
139  always() << " In Map02: " << Gaudi::Utils::toString( map02.end() != map02.find( akey ) ) << endmsg;
140  always() << " In Map03: " << Gaudi::Utils::toString( map03.end() != map03.find( akey ) ) << endmsg;
141  always() << " In Map04: " << Gaudi::Utils::toString( map04.end() != map04.find( akey ) ) << endmsg;
142 
143  return StatusCode::SUCCESS;
144 }
145 // ============================================================================
149 // ============================================================================
150 // The END
151 // ========-===================================================================
std::string
STL class.
Gaudi::Algorithm::index
unsigned int index() const override
Definition: Algorithm.cpp:534
Gaudi::TestSuite::StringKeyEx::Key
Gaudi::StringKey Key
Definition: StringKeyEx.cpp:52
Gaudi::TestSuite::StringKeyEx::m_keys
Gaudi::Property< Keys > m_keys
Definition: StringKeyEx.cpp:56
TestSuite
#define TestSuite
Definition: MakeAndConsume.cpp:634
Gaudi::TestSuite::StringKeyEx::execute
StatusCode execute() override
execution of the Testalg
Definition: StringKeyEx.cpp:66
std::vector
STL class.
GaudiUtils::VectorMap
Definition: VectorMap.h:112
Gaudi::TestSuite::TestAlg
Simple algorithm useful as base class for tests.
Definition: TestAlg.h:19
StringKey.h
TestAlg.h
StatusCode.h
HashMap.h
Gaudi::StringKey
Definition: StringKey.h:44
StatusCode
Definition: StatusCode.h:65
GaudiUtils::Map
Definition: Map.h:91
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:203
std::map< std::string, int >
Gaudi
Header file for std:chrono::duration-based Counters.
Definition: __init__.py:1
Gaudi::Utils::toString
std::string toString(const TYPE &obj)
the generic implementation of the type conversion to the string
Definition: ToStream.h:354
StatusCode::SUCCESS
constexpr static const auto SUCCESS
Definition: StatusCode.h:100
DECLARE_COMPONENT
#define DECLARE_COMPONENT(type)
Definition: PluginServiceV1.h:46
std::make_pair
T make_pair(T... args)
Map.h
GaudiUtils::HashMap< std::string, int >
Gaudi::TestSuite::StringKeyEx
Definition: StringKeyEx.cpp:39
Gaudi::TestSuite::StringKeyEx::m_key
Gaudi::Property< Key > m_key
Definition: StringKeyEx.cpp:55
StringKeyEx
Definition: StringKeyEx.py:1
Gaudi::Property
Implementation of property with value of concrete type.
Definition: Property.h:39
Gaudi::TestSuite::StringKeyEx::Keys
std::vector< Key > Keys
Definition: StringKeyEx.cpp:53