client_ptr.inl
Go to the documentation of this file.
1 namespace iv
2 {
3 
4 template<class TypedClient>
5 client_ptr<TypedClient>::client_ptr( TypedClient * client ) :
6  client( client )
7 {
8  if( this->client )
9  this->addSelfToSC( this->client->instance() );
10 }
11 
12 template<class TypedClient>
14 {
15  this->client = nullptr;
16 }
17 
18 
19 template<class TypedClient>
21  client( other.client )
22 {
23  if( this->client )
24  this->addSelfToSC( this->client->instance() );
25 }
26 
27 template<class TypedClient>
29 {
30  if( this->client )
31  this->removeSelfFromSC( this->client->instance() );
32 }
33 
34 template<class TypedClient>
36 {
37  if( this->client )
38  this->removeSelfFromSC( this->client->instance() );
39  this->client = newClient;
40  if( this->client )
41  this->addSelfToSC( this->client->instance() );
42  return *this;
43 }
44 
45 template<class TypedClient>
47 {
48  if( this == &other )
49  return *this;
50  if( this->client )
51  this->removeSelfFromSC( this->client->instance() );
52  this->client = other.client;
53  if( this->client )
54  this->addSelfToSC( this->client->instance() );
55  return *this;
56 }
57 
58 template<class TypedClient>
60 {
61  return this->client == other.client;
62 }
63 
64 template<class TypedClient>
66 {
67  return this->client != other.client;
68 }
69 
70 template<class TypedClient>
72 {
73  return this->client < other.client;
74 }
75 
76 template<class TypedClient>
78 {
79  return this->client > other.client;
80 }
81 
82 template<class TypedClient>
84 {
85  return this->client <= other.client;
86 }
87 
88 template<class TypedClient>
90 {
91  return this->client >= other.client;
92 }
93 
94 template<class TypedClient>
95 TypedClient * client_ptr<TypedClient>::get ( ) const
96 {
97  return this->client;
98 }
99 
100 template<class TypedClient>
102 {
103  return *this->client;
104 }
105 
106 template<class TypedClient>
108 {
109  return this->client;
110 }
111 
112 template<class TypedClient>
114 {
115  return this->client;
116 }
117 
118 
119 
120 template<class TypedClient>
122 {
123  ( client_ptr< TypedClient > & )( *this ) = ( client_ptr< TypedClient > const & )other;
124  if( this->_change_callback )
125  this->_change_callback();
126  return *this;
127 }
128 
129 template<class TypedClient>
131 {
132  ( client_ptr< TypedClient > & )( *this ) = client;
133  if( this->_change_callback )
134  this->_change_callback();
135  return *this;
136 }
137 
138 template<class TypedClient>
139 void callback_client_ptr< TypedClient >::set_change_callback( std::function< void() > const & cb )
140 {
141  this->_change_callback = cb;
142 }
143 
144 template<class TypedClient>
146 {
148  if( this->_change_callback )
149  this->_change_callback();
150 }
151 
152 }