The Gaudi Framework
v26r1
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Groups
Pages
KeyedObject.cpp
Go to the documentation of this file.
1
// $Id $
2
// Include files
3
#include "GaudiKernel/Kernel.h"
4
#include "GaudiKernel/IRegistry.h"
5
#include "GaudiKernel/LinkManager.h"
6
#include "GaudiKernel/GaudiException.h"
7
#include "GaudiKernel/IDataProviderSvc.h"
8
#include "GaudiKernel/ObjectContainerBase.h"
9
#include "GaudiKernel/ContainedObject.h"
10
16
namespace
Objects {
17
bool
access
(
const
ContainedObject
* from,
ContainedObject
** to);
18
bool
access
(
const
DataObject
* from,
DataObject
** to);
19
20
template
<
class
TO,
class
FROM>
21
TO*
reference
(FROM* from) {
22
ContainedObject
* to = 0;
23
if
(
access
(from, &to) ) {
24
return
dynamic_cast<
TO*
>
(to);
25
}
26
return
0;
27
}
28
}
29
30
bool
Objects::access
(
const
DataObject
* from,
DataObject
** to)
31
{
32
DataObject
* src =
const_cast<
DataObject
*
>
(from);
33
DataObject
* tar = 0;
34
if
( src != 0 )
35
{
36
LinkManager
* mgr = src->
linkMgr
();
37
if
( 0 != mgr )
38
{
39
LinkManager::Link
* link = mgr->
link
(
long
(0));
40
if
( 0 != link )
41
{
42
tar = link->
object
();
43
if
( 0 == tar )
44
{
45
IRegistry
* reg = src->
registry
();
46
if
( 0 != reg )
47
{
48
IDataProviderSvc
* ds = reg->
dataSvc
();
49
if
( 0 != ds )
50
{
51
if
( ds->
retrieveObject
(link->
path
(), tar).isSuccess() )
52
{
53
link->
setObject
(tar);
54
}
55
}
56
}
57
}
58
}
59
}
60
}
61
*to = tar;
62
return
tar != 0;
63
}
64
65
// Load on demand: ContainedObject type references
66
bool
Objects::access
(
const
ContainedObject
* from,
ContainedObject
** to)
67
{
68
*to = 0;
69
if
( from )
70
{
71
DataObject
*tar = 0;
72
if
(
access
(from->
parent
(), &tar) )
73
{
74
ObjectContainerBase
* cnt =
dynamic_cast<
ObjectContainerBase
*
>
(tar);
75
if
( cnt )
76
{
77
*to = cnt->
containedObject
(from->
index
());
78
}
79
}
80
}
81
return
(*to) != 0;
82
}
83
GaudiKernel
src
Lib
KeyedObject.cpp
Generated on Mon Feb 16 2015 11:56:56 for The Gaudi Framework by
1.8.2