Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Gaudi
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Gaudi
Gaudi
Commits
99805385
Commit
99805385
authored
1 year ago
by
Marco Clemencic
Browse files
Options
Downloads
Plain Diff
Cleanup SmartRef (in)equality comparisons
See merge request
!1451
parents
517a957e
5a51e2ab
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!1451
Cleanup SmartRef (in)equality comparisons
Pipeline
#5624512
canceled
1 year ago
Stage: test
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
GaudiKernel/include/GaudiKernel/SmartRef.h
+36
-66
36 additions, 66 deletions
GaudiKernel/include/GaudiKernel/SmartRef.h
with
36 additions
and
66 deletions
GaudiKernel/include/GaudiKernel/SmartRef.h
+
36
−
66
View file @
99805385
...
...
@@ -167,11 +167,17 @@ public:
TYPE
*
data
()
{
return
const_cast
<
TYPE
*>
(
m_target
);
}
const
TYPE
*
data
()
const
{
return
m_target
;
}
/// Access to the object
const
TYPE
*
target
()
const
;
const
TYPE
*
target
()
const
{
if
(
!
m_target
)
{
m_target
=
dynamic_cast
<
const
TYPE
*>
(
m_base
.
accessData
(
m_target
)
);
}
return
m_target
;
}
/// Access to the object
TYPE
*
target
();
TYPE
*
target
()
{
if
(
!
m_target
)
{
m_target
=
dynamic_cast
<
const
TYPE
*>
(
m_base
.
accessData
(
m_target
)
);
}
return
const_cast
<
TYPE
*>
(
m_target
);
}
/// Return the path of the linked object inside the data store.
inline
const
std
::
string
&
path
()
const
{
return
m_base
.
path
();
}
const
std
::
string
&
path
()
const
{
return
m_base
.
path
();
}
/// Equality operator
bool
operator
==
(
const
SmartRef
<
TYPE
>&
c
)
const
{
if
(
m_target
&&
c
.
m_target
)
return
m_target
==
c
.
m_target
;
...
...
@@ -180,8 +186,27 @@ public:
if
(
!
m_target
&&
c
.
m_target
)
return
c
.
m_base
.
isEqualEx
(
c
.
m_target
,
m_base
);
return
false
;
}
/*[[deprecated]]*/
friend
bool
operator
==
(
const
SmartRef
<
TYPE
>&
ref
,
int
)
{
return
ref
.
target
()
==
nullptr
;
}
friend
bool
operator
==
(
const
SmartRef
<
TYPE
>&
ref
,
std
::
nullptr_t
)
{
return
ref
.
target
()
==
nullptr
;
}
/// Friend helper to check for object existence (will load object)
/*[[deprecated]]*/
friend
bool
operator
==
(
int
,
const
SmartRef
<
TYPE
>&
ref
)
{
return
ref
.
target
()
==
nullptr
;
}
friend
bool
operator
==
(
std
::
nullptr_t
,
const
SmartRef
<
TYPE
>&
ref
)
{
return
ref
.
target
()
==
nullptr
;
}
/// NON-Equality operator
bool
operator
!=
(
const
SmartRef
<
TYPE
>&
c
)
const
{
return
!
(
this
->
operator
==
(
c
)
);
}
/*[[deprecated]]*/
friend
bool
operator
!=
(
const
SmartRef
<
TYPE
>&
ref
,
int
)
{
return
ref
.
target
()
!=
nullptr
;
}
friend
bool
operator
!=
(
const
SmartRef
<
TYPE
>&
ref
,
std
::
nullptr_t
)
{
return
ref
.
target
()
!=
nullptr
;
}
/// Friend helper to check for object existence (will load object)
/*[[deprecated]]*/
friend
bool
operator
!=
(
int
,
const
SmartRef
<
TYPE
>&
ref
)
{
return
ref
.
target
()
!=
nullptr
;
}
friend
bool
operator
!=
(
std
::
nullptr_t
,
const
SmartRef
<
TYPE
>&
ref
)
{
return
ref
.
target
()
!=
nullptr
;
}
/// explicit conversion to bool to check for object existence (will load object)
explicit
operator
bool
()
const
{
return
target
()
!=
nullptr
;
}
/// Set the environment (CONST)
const
SmartRef
<
TYPE
>&
_setEnvironment
(
const
DataObject
*
pObj
,
const
ContainedObject
*
pContd
)
const
{
m_base
.
m_data
=
pObj
;
...
...
@@ -237,9 +262,15 @@ public:
/// Implicit type conversion
operator
TYPE
*
()
{
return
SmartRef
<
TYPE
>::
target
();
}
/// Write the reference to the stream buffer (needed due to stupid G++ compiler)
StreamBuffer
&
writeRef
(
StreamBuffer
&
s
)
const
;
StreamBuffer
&
writeRef
(
StreamBuffer
&
s
)
const
{
m_base
.
writeObject
(
m_target
,
s
);
return
s
;
}
/// Read the reference from the stream buffer (needed due to stupid G++ compiler)
StreamBuffer
&
readRef
(
StreamBuffer
&
s
);
StreamBuffer
&
readRef
(
StreamBuffer
&
s
)
{
m_target
=
dynamic_cast
<
TYPE
*>
(
m_base
.
readObject
(
m_target
,
s
)
);
return
s
;
}
/// Output Streamer operator
// MCl: it is "_s" instead of the most common "s" to avoid a fake icc remark #1599
friend
StreamBuffer
&
operator
<<
(
StreamBuffer
&
_s
,
const
SmartRef
<
TYPE
>&
ptr
)
{
return
ptr
.
writeRef
(
_s
);
}
...
...
@@ -248,65 +279,4 @@ public:
friend
StreamBuffer
&
operator
>>
(
StreamBuffer
&
_s
,
SmartRef
<
TYPE
>&
ptr
)
{
return
ptr
.
readRef
(
_s
);
}
};
//
// Inline function necessary to be outside the class definition.
// Mostly this stuff cannot go into the class definition because
// G++ has problems recognizing proper templates if they are not
// completely defined.
//
// M.Frank
//
/// Access to the object
template
<
class
TYPE
>
inline
TYPE
*
SmartRef
<
TYPE
>::
target
()
{
if
(
!
m_target
)
{
m_target
=
dynamic_cast
<
const
TYPE
*>
(
m_base
.
accessData
(
m_target
)
);
}
return
const_cast
<
TYPE
*>
(
m_target
);
}
/// Access to the object (CONST)
template
<
class
TYPE
>
inline
const
TYPE
*
SmartRef
<
TYPE
>::
target
()
const
{
if
(
!
m_target
)
{
m_target
=
dynamic_cast
<
const
TYPE
*>
(
m_base
.
accessData
(
m_target
)
);
}
return
m_target
;
}
/// Write the reference to the stream buffer (needed due to stupid G++ compiler)
template
<
class
TYPE
>
inline
StreamBuffer
&
SmartRef
<
TYPE
>::
writeRef
(
StreamBuffer
&
s
)
const
{
m_base
.
writeObject
(
m_target
,
s
);
return
s
;
}
/// Read the reference from the stream buffer (needed due to stupid G++ compiler)
template
<
class
TYPE
>
inline
StreamBuffer
&
SmartRef
<
TYPE
>::
readRef
(
StreamBuffer
&
s
)
{
m_target
=
dynamic_cast
<
TYPE
*>
(
m_base
.
readObject
(
m_target
,
s
)
);
return
s
;
}
/// Friend helper to check for object existence (will load object)
template
<
class
TYPE
>
inline
bool
operator
==
(
const
SmartRef
<
TYPE
>&
ref
,
int
)
{
return
ref
.
target
()
==
nullptr
;
}
/// Friend helper to check for object existence (will load object)
template
<
class
TYPE
>
inline
bool
operator
==
(
int
,
const
SmartRef
<
TYPE
>&
ref
)
{
return
ref
.
target
()
==
nullptr
;
}
/// Friend helper to check for object existence (will load object)
template
<
class
TYPE
>
inline
bool
operator
!=
(
const
SmartRef
<
TYPE
>&
ref
,
int
)
{
return
ref
.
target
()
!=
nullptr
;
}
/// Friend helper to check for object existence (will load object)
template
<
class
TYPE
>
inline
bool
operator
!=
(
int
,
const
SmartRef
<
TYPE
>&
ref
)
{
return
ref
.
target
()
!=
nullptr
;
}
#endif // KERNEL_SMARTREF_H
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment