Elm  1.0
ELM is a library providing generic data structures, OS-independent interface, plugins and XML.
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Ref.h
1 /*
2  * $Id$
3  * Copyright (c) 2006 - IRIT-UPS <casse@irit.fr>
4  *
5  * Ref class interface.
6  */
7 #ifndef ELM_UTIL_REF_H
8 #define ELM_UTIL_REF_H
9 
10 #include <elm/io.h>
11 
12 namespace elm {
13 
14 using namespace io;
15 
16 // Ref class
17 template <class T>
18 class Ref {
19  T *ptr;
20 public:
21  inline Ref(T *_ptr): ptr(_ptr) { }
22  inline Ref(const Ref<T>& ref): ptr(ref.ptr) { }
23  inline operator T& (void) const { return *ptr; }
24  inline T *operator&(void) const { return ptr; }
25  inline T& operator*(void) const { return *ptr; }
26  inline T *operator->(void) const { return ptr; }
27  inline Ref<T>& operator=(T *_ptr)
28  { ptr = _ptr; return *this; }
29  inline Ref<T>& operator=(const Ref<T>& ref)
30  { ptr = ref.ptr; return *this; }
31  inline Ref<T>& operator=(const T& val)
32  { *ptr = val; return *this; }
33 };
34 
35 // Display
36 template <class T>
37 inline Output& operator<<(Output& out, const Ref<T>& ref) {
38  out << *ref;
39  return out;
40 }
41 
42 } // elm
43 
44 #endif // ELM_UTIL_REF_H
T * operator->(void) const
Definition: Ref.h:26
Ref< T > & operator=(T *_ptr)
Definition: Ref.h:27
Definition: Ref.h:18
Definition: Output.h:161
Ref< T > & operator=(const T &val)
Definition: Ref.h:31
T * operator&(void) const
Definition: Ref.h:24
Ref< T > & operator=(const Ref< T > &ref)
Definition: Ref.h:29
Ref(T *_ptr)
Definition: Ref.h:21
sys::SystemOutStream & out
Definition: system_SystemIO.cpp:101
Ref(const Ref< T > &ref)
Definition: Ref.h:22
T & operator*(void) const
Definition: Ref.h:25