Update ooo320-m1
[ooovba.git] / configmgr / source / inc / treemanager.hxx
blobb261f4e43ee3f9c8406213f2a252511aecbd328b
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: treemanager.hxx,v $
10 * $Revision: 1.7 $
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_TREEMANAGER_HXX_
32 #define CONFIGMGR_TREEMANAGER_HXX_
34 #include <memory>
36 #include "salhelper/simplereferenceobject.hxx"
38 #include "defaultprovider.hxx"
39 #include "confevents.hxx"
40 #include "options.hxx"
41 #include "autoreferencemap.hxx"
42 #include "autoobject.hxx"
44 namespace configmgr
46 namespace uno = ::com::sun::star::uno;
48 namespace backend {
49 class CacheController;
50 class ComponentRequest;
51 class UpdateRequest;
53 namespace sharable {
54 struct TreeFragment;
55 union Node;
58 //==========================================================================
59 //= TreeManager
60 //==========================================================================
61 class CacheClientAccess;
62 class CacheData;
63 class ConfigChangeBroadcastHelper;
64 class ISubtree;
65 //==========================================================================
66 class TreeManager: public salhelper::SimpleReferenceObject {
67 typedef AutoReferenceMap< RequestOptions, CacheClientAccess, lessRequestOptions> CacheList;
69 osl::Mutex m_aCacheControllerMutex;
70 rtl::Reference< backend::CacheController > m_xCacheController;
72 rtl::Reference< backend::CacheController > maybeGetBackendCache() SAL_THROW(());
73 rtl::Reference< backend::CacheController > getCacheLoader() SAL_THROW((com::sun::star::uno::RuntimeException));
74 void disposeBackendCache() SAL_THROW(());
76 CacheList m_aCacheList; // Map
77 AutoObject< CacheData > m_aTemplates;
78 sal_Bool m_bEnableAsync;
80 virtual ~TreeManager();
82 public:
83 /** ctor
85 explicit
86 TreeManager(rtl::Reference< backend::CacheController > const & _xBackend);
88 // disposing the cache before destroying
89 void dispose();
91 /** requests a node given by it's path. Basicly, this means
92 that the node is fetch from the cache when it contains it else it ask the server
93 system into it's cache.
94 @param _rSubtreePath the path to the node in URI notation.
95 @param _nMinLevels indicates how many tree levels under the node determined by <arg>_rSubtreePath</arg>
96 should be loaded
98 sharable::Node * requestSubtree(configuration::AbsolutePath const& _rSubtreePath,
99 RequestOptions const& _aOptions
100 ) SAL_THROW((com::sun::star::uno::Exception));
102 void updateTree(TreeChangeList& aChanges) SAL_THROW((com::sun::star::uno::Exception));
104 void saveAndNotifyUpdate(TreeChangeList const& aChanges) SAL_THROW((com::sun::star::uno::Exception));
106 void releaseSubtree(configuration::AbsolutePath const& aSubtreePath,
107 RequestOptions const& _aOptions ) SAL_THROW(());
109 void fetchSubtree( configuration::AbsolutePath const& aSubtreePath,
110 RequestOptions const& _xOptions
111 ) SAL_THROW(());
113 void refreshAll() SAL_THROW((com::sun::star::uno::Exception));
114 void flushAll() SAL_THROW(());
115 void enableAsync(const sal_Bool& bEnableAsync) SAL_THROW(()) ;
117 sal_Bool fetchDefaultData( configuration::AbsolutePath const& aSubtreePath,
118 RequestOptions const& _aOptions
119 ) SAL_THROW((com::sun::star::uno::Exception));
121 std::auto_ptr<ISubtree> requestDefaultData(configuration::AbsolutePath const& aSubtreePath,
122 const RequestOptions& _aOptions
123 ) SAL_THROW((com::sun::star::uno::Exception));
125 sharable::TreeFragment * requestTemplate( rtl::OUString const& aName, rtl::OUString const& aModule
126 ) SAL_THROW((com::sun::star::uno::Exception));
128 // implementation interfaces
129 void refreshSubtree(const configuration::AbsolutePath &_aAbsoluteSubtreePath,
130 const RequestOptions& _aOptions) SAL_THROW((com::sun::star::uno::Exception));
132 void addListener(configuration::AbsolutePath const& aName, const RequestOptions& _aOptions, rtl::Reference<INodeListener> const& pListener);
133 void removeListener(const RequestOptions& _aOptions, rtl::Reference<INodeListener> const& pListener);
135 void componentCreated(backend::ComponentRequest const & _aComponent) SAL_THROW(());
136 void componentChanged(backend::UpdateRequest const & _anUpdate) SAL_THROW(());
138 private:
139 CacheData & getTemplates() { return * m_aTemplates.get(); }
141 configuration::AbsolutePath encodeTemplateLocation(rtl::OUString const & _rLogicalTemplateName, rtl::OUString const &_rModule);
143 private:
144 rtl::Reference<CacheClientAccess> getCacheAlways(RequestOptions const & _aOptions);
146 // disposing
147 void disposeAll();
149 void fireChanges(TreeChangeList const& _aChanges, sal_Bool _bError);
150 ConfigChangeBroadcastHelper* getBroadcastHelper(RequestOptions const& _aOptions, bool bCreate);
151 void disposeBroadcastHelper(ConfigChangeBroadcastHelper* pHelper);
153 void nodeUpdated(TreeChangeList& _rChanges);
159 #endif