LCOV - code coverage report
Current view: top level - libreoffice/store/source - object.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 2 2 100.0 %
Date: 2012-12-27 Functions: 2 2 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #ifndef _STORE_OBJECT_HXX_
      21             : #define _STORE_OBJECT_HXX_
      22             : 
      23             : #include "sal/types.h"
      24             : 
      25             : #include "rtl/ref.hxx"
      26             : 
      27             : #include "osl/interlck.h"
      28             : 
      29             : namespace store
      30             : {
      31             : 
      32             : /*========================================================================
      33             :  *
      34             :  * IStoreHandle interface.
      35             :  *
      36             :  *======================================================================*/
      37      950970 : class IStoreHandle : public rtl::IReference
      38             : {
      39             : public:
      40             :     /** Replaces dynamic_cast type checking.
      41             :      */
      42             :     virtual sal_Bool SAL_CALL isKindOf (sal_uInt32 nTypeId) = 0;
      43             : 
      44             : protected:
      45      950181 :     ~IStoreHandle() {}
      46             : };
      47             : 
      48             : 
      49             : /** Template helper function as dynamic_cast replacement.
      50             :  */
      51             : template<class store_handle_type>
      52             : store_handle_type * SAL_CALL query (
      53             :     IStoreHandle * pHandle, store_handle_type *);
      54             : 
      55             : /*========================================================================
      56             :  *
      57             :  * OStoreObject interface.
      58             :  *
      59             :  *======================================================================*/
      60             : class OStoreObject : public store::IStoreHandle
      61             : {
      62             :     /** Template function specialization as dynamic_cast replacement.
      63             :      */
      64             :     friend OStoreObject*
      65             :     SAL_CALL query<> (IStoreHandle *pHandle, OStoreObject*);
      66             : 
      67             : public:
      68             :     /** Construction.
      69             :      */
      70             :     OStoreObject (void);
      71             : 
      72             :     /** Allocation.
      73             :      */
      74             :     static void* operator new (size_t n);
      75             :     static void  operator delete (void *p);
      76             : 
      77             :     /** IStoreHandle.
      78             :      */
      79             :     virtual sal_Bool SAL_CALL isKindOf (sal_uInt32 nTypeId);
      80             : 
      81             :     /** IReference.
      82             :      */
      83             :     virtual oslInterlockedCount SAL_CALL acquire (void);
      84             :     virtual oslInterlockedCount SAL_CALL release (void);
      85             : 
      86             : protected:
      87             :     /** Destruction.
      88             :      */
      89             :     virtual ~OStoreObject (void);
      90             : 
      91             : private:
      92             :     /** The IStoreHandle TypeId.
      93             :      */
      94             :     static const sal_uInt32 m_nTypeId;
      95             : 
      96             :     /** Representation.
      97             :      */
      98             :     oslInterlockedCount m_nRefCount;
      99             : 
     100             :     /** Not implemented.
     101             :      */
     102             :     OStoreObject (const OStoreObject&);
     103             :     OStoreObject& operator= (const OStoreObject&);
     104             : };
     105             : 
     106             : /** Template function specialization as dynamic_cast replacement.
     107             :  */
     108             : template<> inline OStoreObject*
     109             : SAL_CALL query (IStoreHandle *pHandle, OStoreObject*)
     110             : {
     111             :     if (pHandle && pHandle->isKindOf (OStoreObject::m_nTypeId))
     112             :     {
     113             :         // Handle is kind of OStoreObject.
     114             :         return static_cast<OStoreObject*>(pHandle);
     115             :     }
     116             :     return 0;
     117             : }
     118             : 
     119             : /*========================================================================
     120             :  *
     121             :  * The End.
     122             :  *
     123             :  *======================================================================*/
     124             : 
     125             : } // namespace store
     126             : 
     127             : #endif /* !_STORE_OBJECT_HXX_ */
     128             : 
     129             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10