]> git.donarmstrong.com Git - lilypond.git/blob - flower/include/pointer.tcc
release: 1.0.1
[lilypond.git] / flower / include / pointer.tcc
1 /*
2   pointer.tcc -- implement P
3
4   source file of the Flower Library
5
6   (c)  1997--1998 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7 */
8
9
10 #ifndef POINTER_TCC
11 #define POINTER_TCC
12
13 template<class T>
14 inline
15 T *
16 P<T>::copy_p() const
17 {
18   return t_p? new T(*t_p) : 0;
19 }
20
21 template<class T>
22 inline
23 void
24 P<T>::copy (T const *l_C)
25 {
26   t_p = l_C ? new T(*l_C) : 0;
27 }
28
29 template<class T>
30 inline
31 void
32 P<T>::junk()
33 {
34   delete t_p;
35   t_p =0;
36 }
37
38 template<class T>
39 inline
40 P<T>::P(P<T> const &s) 
41 {
42   t_p = s.copy_p();
43 }
44
45 template<class T>
46 inline
47 P<T> &
48 P<T>::operator =(P const&s)
49 {
50   junk();
51   copy (s.t_p);
52   return *this;
53 }
54
55 template<class T>
56 inline
57 P<T>::~P() {
58   junk();
59 }
60
61 template<class T>
62 inline
63 void
64 P<T>::set_p (T * np) 
65 {
66   if (np == t_p)
67         return;
68   delete t_p;
69   
70   t_p = np;
71 }
72
73
74 template<class T>
75 inline
76 void
77 P<T>::set_l (T const * l_C) 
78 {
79   if (t_p == l_C)
80         return;
81   
82   junk();
83   copy (l_C);
84 }
85
86
87
88 #endif // POINTER_TCC