ATLAS Offline Software
Loading...
Searching...
No Matches
ToolHandle.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
3*/
4
5// Local include(s):
7#include "AsgTools/IAsgTool.h"
8
9ToolHandleBase::ToolHandleBase( const std::string& typeAndName, INamedInterface* parent )
10: m_typeAndName( typeAndName ), m_type(), m_name(), m_parent(parent) {
11
12 setTypeAndName(typeAndName);
13}
14
15void ToolHandleBase::setTypeAndName(const std::string& typeAndName) {
16 m_typeAndName = typeAndName;
17 // Decode the received string:
18 size_t pos = 0;
19 if( ( pos = m_typeAndName.find( '/' ) ) == std::string::npos ) {
20 // The user specified a single string, which is used as both the type
21 // and instance name.
22 m_type = m_typeAndName;
23 m_name = m_typeAndName;
24 } else {
25 // The user specified both a type and an instance name.
26 m_type = m_typeAndName.substr( 0, pos );
27 m_name = m_typeAndName.substr( pos + 1 );
28 }
29}
30
31void ToolHandleBase::setName(const std::string& name) {
32 m_name = name;
33}
34
35const std::string& ToolHandleBase::typeAndName() const {
36
37 return m_typeAndName;
38}
39
40const std::string& ToolHandleBase::type() const {
41
42 return m_type;
43}
44
45const std::string& ToolHandleBase::name() const {
46
47 return m_name;
48}
49
50const std::string& ToolHandleBase::parentName() const {
51
52 if (m_parent)
53 return m_parent->name();
54 static const std::string toolSvcName = "ToolSvc";
55 return toolSvcName;
56}
57
58INamedInterface *ToolHandleBase ::parent() const noexcept {
59 return m_parent;
60}