cheshirekow  v0.1.0
CPtr.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012 Josh Bialkowski (jbialk@mit.edu)
3  *
4  * This file is part of cppfreetype.
5  *
6  * cppfreetype is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * cppfreetype is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with cppfreetype. If not, see <http://www.gnu.org/licenses/>.
18  */
27 #ifndef CPPFREETYPE_CPTR_H_
28 #define CPPFREETYPE_CPTR_H_
29 
30 
31 namespace freetype {
32 
33 template< class Traits > class RefPtr;
34 
37 template< class Traits >
38 class CPtr
39 {
40  public:
41  typedef typename Traits::cobjptr cobjptr;
42 
43  private:
45 
47  explicit CPtr(cobjptr ptr=0):
48  m_ptr(ptr)
49  {}
50 
52  CPtr( const CPtr<Traits>& other );
53 
56 
57  public:
58  friend class RefPtr<Traits>;
59 
61  {
62  return m_ptr;
63  }
64 
65  const cobjptr operator->() const
66  {
67  return m_ptr;
68  }
69 };
70 
71 
74 template< class Traits >
75 class ConstCPtr
76 {
77  public:
78  typedef typename Traits::cobjptr cobjptr;
79 
80  private:
81  const cobjptr m_ptr;
82 
84  explicit ConstCPtr(const cobjptr ptr=0):
85  m_ptr(ptr)
86  {}
87 
90 
93 
94  public:
95  friend class RefPtr<Traits>;
96 
97  const cobjptr operator->() const
98  {
99  return m_ptr;
100  }
101 };
102 
103 
104 } // namespace cppfreetype
105 
106 
107 #endif // CPTR_H_
Traits::cobjptr cobjptr
Definition: CPtr.h:41
cobjptr m_ptr
Definition: CPtr.h:44
pointer to a reference counted object, auto destruct when reference count is zero ...
Definition: freetype.h:35
CPtr(cobjptr ptr=0)
may only be constructed by a RefPtr
Definition: CPtr.h:47
Traits::cobjptr cobjptr
Definition: CPtr.h:78
ConstCPtr(const cobjptr ptr=0)
may only be constructed by a RefPtr
Definition: CPtr.h:84
CPtr< Traits > & operator=(const CPtr< Traits > &)
not copyable
const cobjptr operator->() const
Definition: CPtr.h:97
acts like a c-pointer by overloading the ->() operator, but is not copyable and doesn't allow the unde...
Definition: CPtr.h:38
acts like a const c-pointer by overloading the ->() operator, but is not copyable and doesn't allow th...
Definition: CPtr.h:75
ConstCPtr< Traits > & operator=(const ConstCPtr< Traits > &)
not copyable
cobjptr operator->()
Definition: CPtr.h:60
BinaryKey other(const BinaryKey &key)
Definition: BinaryKey.h:44
const cobjptr operator->() const
Definition: CPtr.h:65
const cobjptr m_ptr
Definition: CPtr.h:81