LibreOffice Module connectivity (master) 1
SubComponent.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
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#pragma once
21
23#include <osl/diagnose.h>
24#include <osl/mutex.hxx>
25
26namespace cppu { class IPropertyArrayHelper; }
27namespace com::sun::star::lang { class XComponent; }
28
30 {
32 void checkDisposed(bool _bThrow);
33
34
35 template <class TYPE>
37 {
38 protected:
39 static sal_Int32 s_nRefCount;
40 static ::cppu::IPropertyArrayHelper* s_pProps;
41 static ::osl::Mutex s_aMutex;
42
43 public:
46
51
52 protected:
59 virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const = 0;
60 };
61
62 template<class TYPE>
64
65 template<class TYPE>
67
68 template<class TYPE>
70
71
72 template <class TYPE>
74 {
75 ::osl::MutexGuard aGuard(s_aMutex);
76 ++s_nRefCount;
77 }
78
79
80 template <class TYPE>
82 {
83 ::osl::MutexGuard aGuard(s_aMutex);
84 OSL_ENSURE(s_nRefCount > 0, "OPropertyArrayUsageHelper::~OPropertyArrayUsageHelper : suspicious call : have a refcount of 0 !");
85 if (!--s_nRefCount)
86 {
87 delete s_pProps;
88 s_pProps = nullptr;
89 }
90 }
91
92
93 template <class TYPE>
95 {
96 OSL_ENSURE(s_nRefCount, "OPropertyArrayUsageHelper::getArrayHelper : suspicious call : have a refcount of 0 !");
97 if (!s_pProps)
98 {
99 ::osl::MutexGuard aGuard(s_aMutex);
100 if (!s_pProps)
101 {
102 s_pProps = createArrayHelper();
103 OSL_ENSURE(s_pProps, "OPropertyArrayUsageHelper::getArrayHelper : createArrayHelper returned nonsense !");
104 }
105 }
106 return s_pProps;
107 }
108
109}
110
111/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
virtual ::cppu::IPropertyArrayHelper * createArrayHelper() const =0
used to implement the creation of the array helper which is shared amongst all instances of the class...
::cppu::IPropertyArrayHelper * getArrayHelper()
call this in the getInfoHelper method of your derived class.
void checkDisposed(bool _bThrow)
Definition: Driver.cxx:208