Vegastrike 0.5.1 rc1  1.0
Original sources for Vegastrike Evolved
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
clientptr.h
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have recvbufd a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software
14  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
15  */
16 
17 #ifndef CLIENT_PTR_H
18 #define CLIENT_PTR_H
19 
20 #include <map>
21 #include <list>
22 #include <vector>
23 class Client;
24 
25 #ifndef USE_VALGRINDABLE_CLIENTPTR
26 
27 #include "boost/smart_ptr.hpp"
28 #include "boost/weak_ptr.hpp"
29 
30 typedef boost::shared_ptr< Client >ClientPtr;
31 //typedef boost::weak_ptr<Client> ClientWeakPtr;
32 #else
33 
34 template < class T >
35 class NormalPtr
36 {
37  T *val;
38 public: NormalPtr( T *val ) : val( val ) {}
39  NormalPtr( const NormalPtr< T > &p ) : val( p.val ) {}
40  NormalPtr() : val( NULL ) {}
41  ~NormalPtr() {}
42  T&operator*()
43  {
44  return *val;
45  }
46  const T& operator*() const
47  {
48  return *val;
49  }
50  T* operator->()
51  {
52  return val;
53  }
54  const T* operator->() const
55  {
56  return val;
57  }
58  T * get()
59  {
60  return val;
61  }
62  const T * get() const
63  {
64  return val;
65  }
66  void reset()
67  {
68  val = NULL;
69  }
70  bool expired()
71  {
72  return false;
73  }
74  operator bool() const {
75  return val ? true : false;
76  }
77  bool operator!() const
78  {
79  return val ? false : true;
80  }
81 };
82 
83 typedef NormalPtr< Client > ClientPtr;
84 typedef NormalPtr< Client > ClientWeakPtr;
85 #endif
86 
87 typedef std::map< int, ClientPtr > ClientMap;
88 typedef std::pair< int, ClientPtr > ClientPair;
89 typedef std::map< int, ClientPtr >::iterator ClientIt;
90 
91 typedef std::list< ClientPtr > ClientList;
92 //typedef std::list<ClientWeakPtr> ClientWeakList;
93 typedef ClientList::iterator ClientListIt, LI;
94 //typedef ClientWeakList::iterator CWLI;
95 typedef std::vector< ClientList* >::iterator VCLI; //VLI;
96 
97 #endif /* CLIENT_PTR_H */
98