|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 /* |
|
18 * Licensed to the Apache Software Foundation (ASF) under one or more |
|
19 * contributor license agreements. See the NOTICE file distributed with |
|
20 * this work for additional information regarding copyright ownership. |
|
21 * The ASF licenses this file to You under the Apache License, Version 2.0 |
|
22 * (the "License"); you may not use this file except in compliance with |
|
23 * the License. You may obtain a copy of the License at |
|
24 * |
|
25 * http://www.apache.org/licenses/LICENSE-2.0 |
|
26 * |
|
27 * Unless required by applicable law or agreed to in writing, software |
|
28 * distributed under the License is distributed on an "AS IS" BASIS, |
|
29 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
30 * See the License for the specific language governing permissions and |
|
31 * limitations under the License. |
|
32 */ |
|
33 |
|
34 /* |
|
35 * $Id: CountedPointer.hpp 568078 2007-08-21 11:43:25Z amassari $ |
|
36 */ |
|
37 |
|
38 |
|
39 #if !defined(COUNTEDPOINTERTO_HPP) |
|
40 #define COUNTEDPOINTERTO_HPP |
|
41 |
|
42 #include <xercesc/util/NullPointerException.hpp> |
|
43 |
|
44 XERCES_CPP_NAMESPACE_BEGIN |
|
45 |
|
46 template <class T> class CountedPointerTo : public XMemory |
|
47 { |
|
48 public: |
|
49 // ----------------------------------------------------------------------- |
|
50 // Constructors and Destructor |
|
51 // ----------------------------------------------------------------------- |
|
52 CountedPointerTo(const CountedPointerTo<T>& toCopy); |
|
53 CountedPointerTo(T* p = 0); |
|
54 ~CountedPointerTo(); |
|
55 |
|
56 |
|
57 // ----------------------------------------------------------------------- |
|
58 // Operators |
|
59 // ----------------------------------------------------------------------- |
|
60 CountedPointerTo<T>& operator=(const CountedPointerTo<T>& other); |
|
61 operator T*(); |
|
62 const T* operator->() const; |
|
63 T* operator->(); |
|
64 const T& operator*() const; |
|
65 T& operator*(); |
|
66 |
|
67 |
|
68 private: |
|
69 // ----------------------------------------------------------------------- |
|
70 // Data members |
|
71 // |
|
72 // fPtr |
|
73 // The pointer that we are counting. The T type must implement the |
|
74 // addRef() and removeRef() APIs but it doesn't have to derive from |
|
75 // any particular type. |
|
76 // ----------------------------------------------------------------------- |
|
77 T* fPtr; |
|
78 }; |
|
79 |
|
80 XERCES_CPP_NAMESPACE_END |
|
81 |
|
82 #if !defined(XERCES_TMPLSINC) |
|
83 #include <xercesc/util/CountedPointer.c> |
|
84 #endif |
|
85 |
|
86 #endif |