update dev300-m58
[ooovba.git] / configmgr / source / treecache / cacheaccess.hxx
blob3956e7861ca3fbdfab2ebefa95eaed5b34997594
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: cacheaccess.hxx,v $
10 * $Revision: 1.9 $
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_CACHEACCESS_HXX
32 #define CONFIGMGR_CACHEACCESS_HXX
34 #include "cachedata.hxx"
35 #include "timestamp.hxx"
36 #include "utility.hxx"
37 #include <boost/utility.hpp>
38 #include <osl/mutex.hxx>
39 #ifndef _CONFIGMGR_UTILITY_HXX_
40 #include <utility.hxx>
41 #endif
42 #include <rtl/ref.hxx>
43 #include <salhelper/simplereferenceobject.hxx>
45 namespace configmgr
47 ////////////////////////////////////////////////////////////////////////////////
48 class ConfigChangeBroadcastHelper;
49 namespace backend
51 class CacheController;
53 //-----------------------------------------------------------------------------
55 class CacheClientAccess: private boost::noncopyable, public salhelper::SimpleReferenceObject
57 private:
58 CacheData m_aData;
60 ConfigChangeBroadcastHelper* m_pBroadcastHelper;
61 public:
62 explicit
63 CacheClientAccess(ConfigChangeBroadcastHelper* _pBroadcastHelper);
65 ~CacheClientAccess();
67 /// gets a helper to broadcast changes for
68 ConfigChangeBroadcastHelper * getBroadcaster() const
69 { return m_pBroadcastHelper; }
71 /// removes an existing broadcast helper
72 ConfigChangeBroadcastHelper * releaseBroadcaster();
74 // attach a module with a given name
75 void attachModule(sharable::TreeFragment * _aLocation, rtl::OUString const & _aModule);
76 /// check if the given module exists already (and is not empty)
77 bool hasModule(const configuration::AbsolutePath& _aLocation);
78 /// checks if the given module exists and has defaults available
79 bool hasModuleDefaults(configuration::AbsolutePath const & _aLocation);
81 /// retrieve the subtree at _aPath (maybe if it has the requested defaults) and clientAcquire() it
82 sharable::Node * acquireNode(configuration::AbsolutePath const& _aPath);
84 /** add or merge the given subtree at the given location,
85 return <TRUE/> if the tree has defaults then
87 bool insertDefaults( backend::NodeInstance const & _aDefaultData ) SAL_THROW((com::sun::star::uno::RuntimeException));
89 /// clientRelease() the tree at aComponentName, and return the resulting reference count
90 oslInterlockedCount releaseNode( configuration::AbsolutePath const& _aPath );
92 /// retrieve the given subtree without changing its ref count
93 sharable::Node * findInnerNode(configuration::AbsolutePath const& _aPath );
95 /// merge the given change list into this tree - reflects old data to _aUpdate
96 void applyUpdate(backend::UpdateInstance & _aUpdate) SAL_THROW((com::sun::star::uno::RuntimeException));
100 ////////////////////////////////////////////////////////////////////////////////
102 class CacheLoadingAccess: private boost::noncopyable, public salhelper::SimpleReferenceObject
104 public:
105 friend class backend::CacheController;
106 private:
107 friend class CacheDisposeScheduler;
109 ExtendedCacheData m_aData;
110 std::map< rtl::OUString, TimeStamp > m_aDeadModules; /// list of nodes which are registered for throwing away
111 public:
112 explicit
113 CacheLoadingAccess();
114 ~CacheLoadingAccess();
116 /// gets a tree address for the given module if it exists
117 sharable::TreeFragment * getTreeAddress(rtl::OUString const & _aModule);
119 /// return TRUE if there is no data (left) in this object's cache data
120 bool isEmpty();
122 // create a module with a given name
123 void createModule(rtl::OUString const & _aModule);
124 /// check if the given module exists already (and is not empty)
125 bool hasModule(rtl::OUString const & _aLocation);
126 /// retrieve the subtree at aComponentName and clientAcquire() it, true if succeeded
127 bool acquireModule(rtl::OUString const & _aModule);
129 /// clientRelease() the tree at aComponentName, and return the resulting reference count
130 oslInterlockedCount releaseModule( rtl::OUString const & _aModule );
132 /// collect the modules that can be disposed now (i.e. released after _rLimitReleaseTime)
133 TimeStamp collectDisposeList(std::vector< rtl::Reference<CacheLine> > & _rList,
134 TimeStamp const & _aLimitTime,
135 TimeInterval const & _aDelay);
137 // stuff that is particular for CacheLoadingAccess
138 /** add the given subtree at the given location,
139 return the tree that is then pertinent and clientAcquire() it once
141 sharable::TreeFragment * addComponentData( backend::ComponentInstance const & _aComponentInstance,
142 bool _bIncludesDefaults
143 ) SAL_THROW((com::sun::star::uno::RuntimeException));
145 /// merge the given change list into the pending change list of this tree
146 void addChangesToPending( backend::ConstUpdateInstance const& _anUpdate ) SAL_THROW((com::sun::star::uno::RuntimeException));
147 /// retrieve accumulated pending changes
148 std::auto_ptr<SubtreeChange> releasePendingChanges(rtl::OUString const& _aModule);
150 /// find the modules having pending changes
151 bool findPendingChangedModules( std::vector< rtl::OUString > & _rPendingList );
155 ////////////////////////////////////////////////////////////////////////////////
157 } // namespace configmgr
159 #endif