| # Gaudi Framework, version v25r0 |

Home |  | Generated: Mon Feb 17 2014

- 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
SmartDataObjectPtr.cpp
Go to the documentation of this file.
1 // $Header: /tmp/svngaudi/tmp.jEpFh25751/Gaudi/GaudiKernel/src/Lib/SmartDataObjectPtr.cpp,v 1.5 2003/06/25 15:59:40 mato Exp $
2 // ====================================================================
3 // SmartDataObjectPtr.cpp
4 // --------------------------------------------------------------------
5 //
6 // Package :
7 //
8 // Author : Markus Frank
9 //
10 // ====================================================================
11 #define GAUDIKERNEL_SMARTDATAOBJECTPTR_CPP 1
12
13 // Framework include files
14 #include "GaudiKernel/DataObject.h"
15 #include "GaudiKernel/IDataProviderSvc.h"
16 #include "GaudiKernel/SmartDataObjectPtr.h"
17
18 SmartDataObjectPtr::AccessFunction SmartDataObjectPtr::ObjectLoader::access() {
19 return &SmartDataObjectPtr::retrieve;
20 }
21
22 SmartDataObjectPtr::AccessFunction SmartDataObjectPtr::ObjectFinder::access() {
23 return &SmartDataObjectPtr::find;
24 }
25
27 SmartDataObjectPtr& SmartDataObjectPtr::operator=(const SmartDataObjectPtr& copy) {
28 m_path = copy.m_path;
29 m_pRegistry = copy.m_pRegistry;
30 m_dataProvider = copy.m_dataProvider;
31 return *this;
32 }
33
35 StatusCode SmartDataObjectPtr::retrieve(IRegistry* pRegistry, const std::string& path, DataObject*& refpObject) {
36 StatusCode status = StatusCode::FAILURE;
37 if ( 0 != m_dataProvider && 0 != pRegistry ) {
38 status = m_dataProvider->retrieveObject(pRegistry, path, refpObject);
39 }
40 return status;
41 }
42
44 StatusCode SmartDataObjectPtr::retrieve(const std::string& fullPath, DataObject*& refpObject) {
45 StatusCode status = StatusCode::FAILURE;
46 if ( 0 != m_dataProvider ) {
47 status = m_dataProvider->retrieveObject(fullPath, refpObject);
48 }
49 return status;
50 }
51
53 StatusCode SmartDataObjectPtr::find(IRegistry* pDirectory, const std::string& path, DataObject*& refpObject) {
54 StatusCode status = StatusCode::FAILURE;
55 if ( 0 != m_dataProvider && 0 != pDirectory ) {
56 status = m_dataProvider->findObject(pDirectory, path, refpObject);
57 }
58 return status;
59 }
60
62 StatusCode SmartDataObjectPtr::find(const std::string& fullPath, DataObject*& refpObject) {
63 StatusCode status = StatusCode::FAILURE;
64 if ( 0 != m_dataProvider ) {
65 status = m_dataProvider->findObject(fullPath, refpObject);
66 }
67 return status;
68 }
69
70
72 StatusCode SmartDataObjectPtr::update(IRegistry* pRegistry) {
73 StatusCode status = StatusCode::FAILURE;
74 if ( 0 != m_dataProvider && 0 != pRegistry ) {
75 status = m_dataProvider->updateObject(pRegistry);
76 }
77 return status;
78 }
79
81 StatusCode SmartDataObjectPtr::update(const std::string& fullPath) {
82 StatusCode status = StatusCode::FAILURE;
83 if ( 0 != m_dataProvider ) {
84 status = m_dataProvider->updateObject(fullPath);
85 }
86 return status;
87 }
88
94 DataObject* SmartDataObjectPtr::retrieveObject() {
95 DataObject* pObj = 0;
96 m_status = (0==m_pRegistry) ? retrieve(m_path,pObj) : retrieve(m_pRegistry,m_path,pObj);
97 if ( m_status.isSuccess() ) {
98 m_pRegistry = pObj->registry();
99 m_path = "";
100 }
101 return pObj;
102 }
103
109 DataObject* SmartDataObjectPtr::findObject() {
110 DataObject* pObj = 0;
111 m_status = (0==m_pRegistry) ? find(m_path,pObj) : find(m_pRegistry,m_path,pObj);
112 if ( m_status.isSuccess() ) {
113 m_pRegistry = pObj->registry();
114 m_path = "";
115 }
116 return pObj;
117 }
118
124 DataObject* SmartDataObjectPtr::updateObject() {
125 DataObject* pObj = accessData(); // Have to load AND update if not present.
126 if ( m_status.isSuccess() ) {
127 m_status = (0 == m_pRegistry) ? update(m_path) : update(m_pRegistry);
128 if ( !m_status.isSuccess() ) pObj = 0;
129 }
130 return pObj;
131 }
132
145 bool operator&& (SmartDataObjectPtr& object_1, SmartDataObjectPtr& object_2) {
146 if ( 0 != object_1.accessData() ) { // Test existence of the first object
147 if ( 0 != object_2.accessData() ) { // Test existence of the second object
148 return true; // Fine: Both objects exist
149 }
150 }
151 return false; // Tough luck: One is missing.
152 }
153
170 bool operator|| (SmartDataObjectPtr& object_1, SmartDataObjectPtr& object_2) {
171 if ( 0 != object_1.accessData() ) { // Test existence of the first object
172 return true;
173 }
174 if ( 0 != object_2.accessData() ) { // Test existence of the second object
175 return true;
176 }
177 return false; // Tough luck: Both are missing.
178 }
179