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 23 24 25 #ifndef _VOS_REFOBJ_HXX_ 26 #define _VOS_REFOBJ_HXX_ 27 28 /** 29 ORefObj<T> 30 31 template type to implement handle/body behaviour 32 with reference-counting. 33 */ 34 35 # include <vos/refernce.hxx> 36 #ifndef _VOS_DIAGNOSE_HXX_ 37 # include <vos/diagnose.hxx> 38 #endif 39 40 namespace vos 41 { 42 43 template <class T> 44 class ORefObj : public IReference 45 { 46 public: 47 ORefObj(const T& Obj); 48 49 inline ~ORefObj(); 50 acquire()51 virtual RefCount SAL_CALL acquire() 52 { return (m_RefCount.acquire()); } release()53 virtual RefCount SAL_CALL release() 54 { return (m_RefCount.release()); } referenced() const55 virtual RefCount SAL_CALL referenced() const 56 { return (m_RefCount.referenced()); } 57 58 T& SAL_CALL operator=(const T& Obj); 59 60 SAL_CALL operator T&(); 61 SAL_CALL operator const T&() const; 62 63 T& SAL_CALL operator() (); 64 const T& SAL_CALL operator() () const; 65 66 const T& SAL_CALL getObj() const; 67 T& SAL_CALL getObj(); 68 69 protected: 70 T m_Obj; 71 ORefCount m_RefCount; 72 73 private: 74 ORefObj(const ORefObj<T>& handle); 75 ORefObj<T>& SAL_CALL operator= (const ORefObj<T>& handle); 76 }; 77 78 // include template implementation 79 #include <vos/refobj.inl> 80 81 } 82 83 84 #endif // _VOS_REF_HXX_ 85 86