/************************************************************** * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * *************************************************************/ #if (defined(OS2) && defined(ICC)) #define CAST_TO_IREFERENCE(p) ((IReference*)(p)) #else #define CAST_TO_IREFERENCE(p) (p) #endif template inline ORef::ORef() { m_refBody= 0; } template inline ORef::ORef(T* pBody) { m_refBody= pBody; if (m_refBody) CAST_TO_IREFERENCE(m_refBody)->acquire(); } template inline ORef::ORef(const ORef& handle) { m_refBody= handle.m_refBody; if (m_refBody) CAST_TO_IREFERENCE(m_refBody)->acquire(); } template inline ORef::~ORef() { if (m_refBody) CAST_TO_IREFERENCE(m_refBody)->release(); } template inline ORef& ORef::operator= (const ORef& handle) { if (m_refBody) CAST_TO_IREFERENCE(m_refBody)->release(); m_refBody= handle.m_refBody; if (m_refBody) CAST_TO_IREFERENCE(m_refBody)->acquire(); return *this; } template inline void ORef::bind(T* pBody) { if (m_refBody) CAST_TO_IREFERENCE(m_refBody)->release(); m_refBody= pBody; if (m_refBody) CAST_TO_IREFERENCE(m_refBody)->acquire(); } template inline ORef& ORef::unbind() { if (m_refBody) { CAST_TO_IREFERENCE(m_refBody)->release(); m_refBody = 0; } return *this; } template inline void ORef::operator= (T* pBody) { bind(pBody); } template inline T& ORef::operator() () const { VOS_PRECOND(m_refBody, "ORef::operator(): can't deref nil body!"); return *m_refBody; } template inline T& ORef::operator* () const { VOS_PRECOND(m_refBody, "ORef::operator*: can't deref nil body!"); return *m_refBody; } template inline T* ORef::operator->() const { VOS_PRECOND(m_refBody, "ORef::operator->: nil body!"); return m_refBody; } template inline T& ORef::getBody() const { VOS_PRECOND(m_refBody, "ORef::getBody(): can't deref nil body!"); return *m_refBody; } template inline T* ORef::getBodyPtr() const { // might be nil return m_refBody; } template inline sal_Bool ORef::isEmpty() const { return m_refBody == 0; } template inline sal_Bool ORef::isValid() const { return m_refBody != 0; } template inline sal_Bool ORef::isEqualBody(const ORef& handle) const { return m_refBody == handle.m_refBody; } template inline sal_Bool ORef::operator== (const ORef& handle) const { return m_refBody == handle.m_refBody; } template inline sal_Bool ORef::operator!= (const ORef& handle) const { return m_refBody != handle.m_refBody; } template inline sal_Bool ORef::operator== (const T* pBody) const { return m_refBody == pBody; } template inline sal_Bool ORef::operator< (const ORef& handle) const { return m_refBody < handle.m_refBody; } template inline sal_Bool ORef::operator> (const ORef& handle) const { return m_refBody > handle.m_refBody; }