PolyBoRi
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
libpolybori
include
polybori
common
CWeakPtr.h
Go to the documentation of this file.
1
// -*- c++ -*-
2
//*****************************************************************************
14
//*****************************************************************************
15
16
#ifndef polybori_CWeakPtr_h_
17
#define polybori_CWeakPtr_h_
18
19
// include basic definitions
20
#include <
polybori/pbori_defs.h
>
21
#include "
CWeakPtrFacade.h
"
22
23
BEGIN_NAMESPACE_PBORI
24
30
template
<
class
ValueType>
31
class
CWeakPtr
{
32
33
typedef
CWeakPtr
self
;
34
35
public
:
36
typedef
ValueType
value_type
;
37
38
typedef
value_type
*
data_type
;
39
typedef
boost::shared_ptr<data_type>
ptr_type
;
40
41
43
explicit
CWeakPtr
(
const
CWeakPtrFacade<ValueType>
& val):
44
m_data(val.m_data) {
PBORI_ASSERT
(m_data);}
45
47
CWeakPtr
(
const
self
& rhs): m_data(rhs.m_data) {}
48
50
~CWeakPtr
() {}
51
53
const
value_type
&
operator*
()
const
{
54
return
*(operator->());
55
}
56
58
value_type
*
operator->
()
const
{
59
if
(!*m_data)
60
throw
std::runtime_error(
"Outdated weak pointer dereferenced."
);
61
62
return
(*m_data);
63
}
65
operator
bool()
const
{
return
*m_data; }
66
67
private
:
68
ptr_type m_data;
69
};
70
71
END_NAMESPACE_PBORI
72
73
#endif
/* polybori_CWeakPtr_h_ */
Generated by
1.8.3.1