ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/include/util.h
(Generate patch)

Comparing deliantra/server/include/util.h (file contents):
Revision 1.21 by root, Thu Dec 21 06:12:36 2006 UTC vs.
Revision 1.25 by root, Sat Dec 30 10:16:10 2006 UTC

6#else 6#else
7# define is_constant(c) 0 7# define is_constant(c) 0
8#endif 8#endif
9 9
10#include <cstddef> 10#include <cstddef>
11#include <new>
12#include <vector>
11 13
12#include <glib.h> 14#include <glib.h>
15
16#include <shstr.h>
17#include <traits.h>
13 18
14// use a gcc extension for auto declarations until ISO C++ sanctifies them 19// use a gcc extension for auto declarations until ISO C++ sanctifies them
15#define AUTODECL(var,expr) typeof(expr) var = (expr) 20#define AUTODECL(var,expr) typeof(expr) var = (expr)
16 21
17// makes dynamically allocated objects zero-initialised 22// makes dynamically allocated objects zero-initialised
120 { 125 {
121 p->~Tp (); 126 p->~Tp ();
122 } 127 }
123}; 128};
124 129
125struct refcounted
126{
127 refcounted () : refcnt (0) { }
128// virtual ~refcounted ();
129 void refcnt_inc () { ++refcnt; }
130 void refcnt_dec () { --refcnt; }
131 bool dead () { return refcnt == 0; }
132 mutable int refcnt;
133#if 0
134private:
135 static refcounted *rc_first;
136 refcounted *rc_next;
137#endif
138};
139
140template<class T> 130template<class T>
141struct refptr 131struct refptr
142{ 132{
143 T *p; 133 T *p;
144 134
165 T &operator * () const { return *p; } 155 T &operator * () const { return *p; }
166 T *operator ->() const { return p; } 156 T *operator ->() const { return p; }
167 157
168 operator T *() const { return p; } 158 operator T *() const { return p; }
169}; 159};
160
161typedef refptr<maptile> maptile_ptr;
162typedef refptr<object> object_ptr;
163typedef refptr<archetype> arch_ptr;
164typedef refptr<client> client_ptr;
165typedef refptr<player> player_ptr;
170 166
171struct str_hash 167struct str_hash
172{ 168{
173 std::size_t operator ()(const char *s) const 169 std::size_t operator ()(const char *s) const
174 { 170 {
200 { 196 {
201 return !strcmp (a, b); 197 return !strcmp (a, b);
202 } 198 }
203}; 199};
204 200
205#include <vector>
206
207template<class obj> 201template<class obj>
208struct unordered_vector : std::vector<obj, slice_allocator<obj> > 202struct unordered_vector : std::vector<obj, slice_allocator<obj> >
209{ 203{
210 typedef typename unordered_vector::iterator iterator; 204 typedef typename unordered_vector::iterator iterator;
211 205
242typedef double tstamp; 236typedef double tstamp;
243 237
244// return current time as timestampe 238// return current time as timestampe
245tstamp now (); 239tstamp now ();
246 240
241int similar_direction (int a, int b);
242
247#endif 243#endif
248 244

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines