1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: apitreeimplobj.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef CONFIGMGR_API_TREEIMPLOBJECTS_HXX_
32 #define CONFIGMGR_API_TREEIMPLOBJECTS_HXX_
34 #include "noderef.hxx"
35 #include "configset.hxx"
36 #include "configdefaultprovider.hxx"
37 #include "confevents.hxx"
38 #include "options.hxx"
39 #include "utility.hxx"
40 #include <boost/utility.hpp>
41 #include <vos/ref.hxx>
42 #include <rtl/ref.hxx>
43 #include <osl/mutex.hxx>
45 #ifndef INCLUDED_MEMORY
47 #define INCLUDED_MEMORY
49 #include <com/sun/star/lang/XEventListener.hpp>
50 #include <com/sun/star/lang/XComponent.hpp>
52 namespace com
{ namespace sun
{ namespace star
{
53 namespace script
{ class XTypeConverter
; }
58 //-----------------------------------------------------------------------------
60 //-----------------------------------------------------------------------------
63 //-----------------------------------------------------------------------------
67 //-----------------------------------------------------------------------------
69 //-----------------------------------------------------------------------------
70 // API object implementation wrappers
71 //-------------------------------------------------------------------------
72 class ApiProvider
: private boost::noncopyable
75 OProviderImpl
& m_rProviderImpl
;
77 ApiProvider(Factory
& rFactory
, OProviderImpl
& rProviderImpl
);
82 uno::Reference
<com::sun::star::script::XTypeConverter
> getTypeConverter() const;
83 Factory
& getFactory() { return m_rFactory
; }
84 OProviderImpl
& getProviderImpl() { return m_rProviderImpl
; }
87 //-----------------------------------------------------------------------------
89 //-------------------------------------------------------------------------
90 class ApiTreeImpl
: private boost::noncopyable
92 class ComponentAdapter
;
94 rtl::Reference
< configuration::Tree
> m_aTree
;
95 vos::ORef
<NotifierImpl
> m_aNotifier
;
96 configuration::DefaultProvider m_aDefaultProvider
;
97 uno::Reference
<ComponentAdapter
> m_xProvider
;
98 ApiProvider
& m_rProvider
;
99 ApiTreeImpl
* m_pParentTree
;
100 uno::XInterface
* m_pInstance
;
103 explicit ApiTreeImpl(uno::XInterface
* pInstance
, ApiProvider
& rProvider
, rtl::Reference
< configuration::Tree
> const& aTree
, ApiTreeImpl
* pParentTree
);
104 explicit ApiTreeImpl(uno::XInterface
* _pInstance
, ApiProvider
& _rProvider
, rtl::Reference
< configuration::Tree
> const& _aTree
, configuration::DefaultProvider
const & _aDefaultProvider
);
108 void setNodeInstance(configuration::NodeRef
const& aNode
, uno::XInterface
* pInstance
);
111 rtl::Reference
< configuration::Tree
> getTree() const { return m_aTree
; }
113 // self-locked methods for dispose handling
114 bool isAlive() const;
115 void checkAlive() const;
116 bool disposeTree(bool bForce
);
117 bool disposeTreeNow();
118 void disposeNode(configuration::NodeRef
const& aNode
, uno::XInterface
* pInstance
);
120 // api object handling
121 Factory
& getFactory() const { return m_rProvider
.getFactory(); }
122 Notifier
getNotifier() const;
123 configuration::DefaultProvider
getDefaultProvider() const { return m_aDefaultProvider
; }
125 // needs external locking
126 ApiTreeImpl
const* getRootTreeImpl() const;
128 uno::XInterface
* getUnoInstance() const { return m_pInstance
; }
129 ApiProvider
& getProvider() { return m_rProvider
; }
130 uno::Reference
<uno::XInterface
> getUnoProviderInstance() const; // { return m_xProvider; }
132 /// wire this to a new parent tree
133 void haveNewParent(ApiTreeImpl
* pNewParent
);
135 void init(ApiTreeImpl
* pParentTree
);
136 void setParentTree(ApiTreeImpl
* pNewParentTree
);
139 bool implDisposeTree();
140 void implDisposeNode(configuration::NodeRef
const& aNode
, uno::XInterface
* pInstance
);
142 friend class ComponentAdapter
;
143 void disposing(com::sun::star::lang::EventObject
const& rEvt
) throw();
144 uno::Reference
<com::sun::star::lang::XComponent
> getProviderComponent();
145 uno::Reference
<com::sun::star::lang::XComponent
> getParentComponent();
149 //-----------------------------------------------------------------------------
150 class ApiRootTreeImpl
153 explicit ApiRootTreeImpl(uno::XInterface
* pInstance
, ApiProvider
& rProvider
, rtl::Reference
< configuration::Tree
> const& aTree
, vos::ORef
< OOptions
> const& _xOptions
);
156 ApiTreeImpl
& getApiTree() { return m_aTreeImpl
; }
157 ApiTreeImpl
const& getApiTree() const { return m_aTreeImpl
; }
159 configuration::AbsolutePath
const & getLocation() const { return m_aLocationPath
; }
160 vos::ORef
< OOptions
> getOptions() const { return m_xOptions
; }
162 // self-locked methods for dispose handling
165 /// toggle whether this object relays notifications from the base provider
166 bool enableNotification(bool bEnable
);
168 TreeManager
* implSetNotificationSource(TreeManager
* pNew
);
169 void implSetLocation(rtl::Reference
< configuration::Tree
> const& _aTree
);
174 friend class NodeListener
;
177 void disposing(TreeManager
* pSource
) ;
178 //INodeListener : IConfigListener
179 void nodeChanged(Change
const& aChange
, configuration::AbsolutePath
const& aPath
, TreeManager
* pSource
);
180 void nodeDeleted(configuration::AbsolutePath
const& aPath
, TreeManager
* pSource
);
183 ApiTreeImpl m_aTreeImpl
;
184 configuration::AbsolutePath m_aLocationPath
;
185 rtl::Reference
<NodeListener
> m_pNotificationListener
;
186 vos::ORef
< OOptions
> m_xOptions
;
188 //-----------------------------------------------------------------------------
192 #endif // CONFIGMGR_API_TREEIMPLOBJECTS_HXX_