3
*************************************************************************
5
ArmageTron -- Just another Tron Lightcycle Game in 3D.
6
Copyright (C) 2000 Manuel Moos (manuel@moosnet.de)
8
**************************************************************************
10
This program is free software; you can redistribute it and/or
11
modify it under the terms of the GNU General Public License
12
as published by the Free Software Foundation; either version 2
13
of the License, or (at your option) any later version.
15
This program is distributed in the hope that it will be useful,
16
but WITHOUT ANY WARRANTY; without even the implied warranty of
17
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
GNU General Public License for more details.
20
You should have received a copy of the GNU General Public License
21
along with this program; if not, write to the Free Software
22
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24
***************************************************************************
28
#ifndef ArmageTron_OBSERVER_H
29
#define ArmageTron_OBSERVER_H
36
class nObserver: public tReferencable< nObserver >
38
friend class tReferencable< nObserver >;
40
const nNetObject* GetNetObject() const; // returns the observed object
43
static void SetLastChecked( const nObserver* checked );
44
static bool WasChecked( const nObserver* checked );
48
const nNetObject* object_; // the observed object
50
void SetObject( const nNetObject *); // sets the observed object
55
friend class nNetObject;
66
nObserver::SetLastChecked( this->observer_ );
69
return ( bool( this->observer_ ) && this->observer_->GetNetObject() );
72
bool operator!() const
74
return !operator bool();
77
const T* GetPointer() const
79
if ( this->observer_ )
80
return dynamic_cast< const T* >( observer_->GetNetObject() );
85
operator const T* () const
87
return this->GetPointer();
90
const T* operator->() const
95
// tASSERT( nObserver::WasChecked( this->observer_ ) );
103
const T* operator*() const
108
// tASSERT( nObserver::WasChecked( this->observer_ ) );
116
void SetObject ( const T* t)
121
observer_ = &t->GetObserver();
124
nObserverPtr& operator = ( const T* t)
131
nObserverPtr( const T* t)
140
tCONTROLLED_PTR( nObserver ) observer_;