update dev300-m58
[ooovba.git] / configmgr / source / api2 / apitreeimplobj.hxx
blob087893e8172f7fd3f2e10dadaba3852e0846ff2d
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: apitreeimplobj.hxx,v $
10 * $Revision: 1.27 $
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
46 #include <memory>
47 #define INCLUDED_MEMORY
48 #endif
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; }
54 } } }
56 namespace configmgr
58 //-----------------------------------------------------------------------------
59 class OProviderImpl;
60 //-----------------------------------------------------------------------------
61 namespace configapi
63 //-----------------------------------------------------------------------------
64 class Factory;
65 class Notifier;
66 class NotifierImpl;
67 //-----------------------------------------------------------------------------
68 class ObjectRegistry;
69 //-----------------------------------------------------------------------------
70 // API object implementation wrappers
71 //-------------------------------------------------------------------------
72 class ApiProvider: private boost::noncopyable
74 Factory& m_rFactory;
75 OProviderImpl& m_rProviderImpl;
76 public:
77 ApiProvider(Factory& rFactory, OProviderImpl& rProviderImpl );
79 ~ApiProvider()
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;
102 public:
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);
105 ~ApiTreeImpl();
107 // initialization
108 void setNodeInstance(configuration::NodeRef const& aNode, uno::XInterface* pInstance);
110 // model access
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);
134 private:
135 void init(ApiTreeImpl* pParentTree);
136 void setParentTree(ApiTreeImpl* pNewParentTree);
137 void deinit();
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
152 public:
153 explicit ApiRootTreeImpl(uno::XInterface* pInstance, ApiProvider& rProvider, rtl::Reference< configuration::Tree > const& aTree, vos::ORef< OOptions > const& _xOptions);
154 ~ApiRootTreeImpl();
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
163 bool disposeTree();
165 /// toggle whether this object relays notifications from the base provider
166 bool enableNotification(bool bEnable);
167 private:
168 TreeManager * implSetNotificationSource(TreeManager * pNew);
169 void implSetLocation(rtl::Reference< configuration::Tree > const& _aTree);
170 void releaseData();
172 private:
173 class NodeListener;
174 friend class NodeListener;
176 // IConfigListener
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);
182 private:
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_