LCOV - code coverage report
Current view: top level - store/source - object.hxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 2 2 100.0 %
Date: 2014-04-11 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        1931 : class IStoreHandle : public rtl::IReference
      38             : {
      39             : public:
      40             :     /** Replaces dynamic_cast type checking.
      41             :      */
      42             :     virtual bool isKindOf (sal_uInt32 nTypeId) = 0;
      43             : 
      44             : protected:
      45        1931 :     ~IStoreHandle() {}
      46             : };
      47             : 
      48             : /** Template helper function as dynamic_cast replacement.
      49             :  */
      50             : template<class store_handle_type>
      51             : store_handle_type * SAL_CALL query (
      52             :     IStoreHandle * pHandle, store_handle_type *);
      53             : 
      54             : /*========================================================================
      55             :  *
      56             :  * OStoreObject interface.
      57             :  *
      58             :  *======================================================================*/
      59             : class OStoreObject : public store::IStoreHandle
      60             : {
      61             :     /** Template function specialization as dynamic_cast replacement.
      62             :      */
      63             :     friend OStoreObject*
      64             :     SAL_CALL query<> (IStoreHandle *pHandle, OStoreObject*);
      65             : 
      66             : public:
      67             :     /** Construction.
      68             :      */
      69             :     OStoreObject (void);
      70             : 
      71             :     /** Allocation.
      72             :      */
      73             :     static void* operator new (size_t n);
      74             :     static void  operator delete (void *p);
      75             : 
      76             :     /** IStoreHandle.
      77             :      */
      78             :     virtual bool isKindOf (sal_uInt32 nTypeId) SAL_OVERRIDE;
      79             : 
      80             :     /** IReference.
      81             :      */
      82             :     virtual oslInterlockedCount SAL_CALL acquire (void) SAL_OVERRIDE;
      83             :     virtual oslInterlockedCount SAL_CALL release (void) SAL_OVERRIDE;
      84             : 
      85             : protected:
      86             :     /** Destruction.
      87             :      */
      88             :     virtual ~OStoreObject (void);
      89             : 
      90             : private:
      91             :     /** The IStoreHandle TypeId.
      92             :      */
      93             :     static const sal_uInt32 m_nTypeId;
      94             : 
      95             :     /** Representation.
      96             :      */
      97             :     oslInterlockedCount m_nRefCount;
      98             : 
      99             :     /** Not implemented.
     100             :      */
     101             :     OStoreObject (const OStoreObject&);
     102             :     OStoreObject& operator= (const OStoreObject&);
     103             : };
     104             : 
     105             : /** Template function specialization as dynamic_cast replacement.
     106             :  */
     107             : template<> inline OStoreObject*
     108             : SAL_CALL query (IStoreHandle *pHandle, OStoreObject*)
     109             : {
     110             :     if (pHandle && pHandle->isKindOf (OStoreObject::m_nTypeId))
     111             :     {
     112             :         // Handle is kind of OStoreObject.
     113             :         return static_cast<OStoreObject*>(pHandle);
     114             :     }
     115             :     return 0;
     116             : }
     117             : 
     118             : /*========================================================================
     119             :  *
     120             :  * The End.
     121             :  *
     122             :  *======================================================================*/
     123             : 
     124             : } // namespace store
     125             : 
     126             : #endif /* !_STORE_OBJECT_HXX_ */
     127             : 
     128             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10