xref: /AOO42X/main/vos/inc/vos/refobj.hxx (revision bd9c563a4d9fd6e5d60bab5e648229ea17ff5bf4)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 #ifndef _VOS_REFOBJ_HXX_
23 #define _VOS_REFOBJ_HXX_
24 
25 /**
26     ORefObj<T>
27 
28     template type to implement handle/body behavior
29     with reference-counting.
30 */
31 
32 #   include <vos/refernce.hxx>
33 #ifndef _VOS_DIAGNOSE_HXX_
34 #   include <vos/diagnose.hxx>
35 #endif
36 
37 namespace vos
38 {
39 
40 template <class T>
41 class ORefObj : public IReference
42 {
43 public:
44     ORefObj(const T& Obj);
45 
46     inline ~ORefObj();
47 
acquire()48     virtual RefCount SAL_CALL acquire()
49         { return (m_RefCount.acquire()); }
release()50     virtual RefCount SAL_CALL release()
51         { return (m_RefCount.release()); }
referenced() const52     virtual RefCount SAL_CALL referenced() const
53         { return (m_RefCount.referenced()); }
54 
55     T& SAL_CALL operator=(const T& Obj);
56 
57     SAL_CALL operator T&();
58     SAL_CALL operator const T&() const;
59 
60     T& SAL_CALL operator() ();
61     const T& SAL_CALL operator() () const;
62 
63     const   T& SAL_CALL getObj() const;
64     T& SAL_CALL getObj();
65 
66 protected:
67     T         m_Obj;
68     ORefCount m_RefCount;
69 
70 private:
71     ORefObj(const ORefObj<T>& handle);
72     ORefObj<T>& SAL_CALL operator= (const ORefObj<T>& handle);
73 };
74 
75 // include template implementation
76 #include <vos/refobj.inl>
77 
78 }
79 
80 #endif // _VOS_REF_HXX_
81 
82 /* vim: set noet sw=4 ts=4: */
83