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: cachedata.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_CACHEDATA_HXX
32 #define CONFIGMGR_CACHEDATA_HXX
34 #include "cacheline.hxx"
41 #ifndef INCLUDED_VECTOR
43 #define INCLUDED_VECTOR
48 ////////////////////////////////////////////////////////////////////////////////
52 struct TemplateInstance
;
53 struct UpdateInstance
;
54 struct ConstUpdateInstance
;
57 ////////////////////////////////////////////////////////////////////////////////
58 /** A collection of CacheLines
67 // attach a module with a given name
68 void attachModule(sharable::TreeFragment
* _aLocation
, rtl::OUString
const & _aModule
);
69 /// check if the given module exists already (and is not empty)
70 bool hasModule(rtl::OUString
const & _aModule
) const;
71 /// checks if the given module exists and has defaults available
72 bool hasModuleDefaults(rtl::OUString
const & _aModule
) const;
74 /// gets a tree address for the given module if it exists
75 sharable::TreeFragment
* getTreeAddress(rtl::OUString
const & _aModule
) const;
77 /// checks whether a certain node exists in the tree
78 bool hasNode(configuration::AbsolutePath
const & _aLocation
) const;
80 /// retrieve the given node without changing its ref count
81 sharable::Node
* getNode(configuration::AbsolutePath
const & _rPath
);
82 /// retrieve the given template tree without changing its ref count
83 sharable::TreeFragment
* getTemplateTree( configuration::AbsolutePath
const & aTemplateName
) const;
85 /// retrieve the subtree at _aPath and clientAcquire() it
86 sharable::Node
* acquireNode(configuration::AbsolutePath
const & _aPath
);
87 /// retrieve the subtree at _aPath and clientAcquire() it, return true on success
88 bool acquireModule( rtl::OUString
const & _aModule
);
89 /// clientRelease() the tree at aComponentName, and return the resulting reference count
90 oslInterlockedCount
releaseModule( rtl::OUString
const & _aModule
, bool _bKeepDeadModule
= false );
92 bool insertDefaults( backend::NodeInstance
const & _aDefaultInstance
93 ) SAL_THROW((com::sun::star::uno::RuntimeException
));
95 /// merge the given changes into this tree - reflects old values to _anUpdate
96 void applyUpdate( backend::UpdateInstance
& _anUpdate
) SAL_THROW((com::sun::star::uno::RuntimeException
));
98 // low-level interface for cache management
99 typedef std::map
<rtl::OUString
, rtl::Reference
<CacheLine
> > ModuleList
;
100 ModuleList
& accessModuleList() { return m_aModules
; }
103 virtual rtl::Reference
<CacheLine
> doCreateAttachedModule(sharable::TreeFragment
* _aLocation
, rtl::OUString
const & _aName
) SAL_THROW((com::sun::star::uno::RuntimeException
));
105 sharable::TreeFragment
* internalGetPartialTree(configuration::AbsolutePath
const & _aPath
) const;
106 sharable::Node
* internalGetNode(const configuration::AbsolutePath
& _rPath
) const;
108 rtl::Reference
<CacheLine
> internalAttachModule(sharable::TreeFragment
* _aLocation
, rtl::OUString
const & _aName
) SAL_THROW((com::sun::star::uno::RuntimeException
));
109 void internalAddModule(rtl::OUString
const & _aName
, rtl::Reference
<CacheLine
> const & _aModule
);
111 rtl::Reference
<CacheLine
> internalGetModule(rtl::OUString
const & _aName
) const;
112 rtl::Reference
<CacheLine
> internalGetModule(const configuration::AbsolutePath
& _aLocation
) const;
115 ModuleList m_aModules
;
117 ////////////////////////////////////////////////////////////////////////////////
118 /** A collection of CacheLines for templates
121 class TemplateCacheData
: public CacheData
124 TemplateCacheData() : CacheData()
128 /** add the given template tree at the given location,
129 return the tree that is now pertinent and clientAcquire() it once
131 sharable::TreeFragment
* addTemplates( backend::ComponentDataStruct
const & _aComponentInstance
132 ) SAL_THROW((com::sun::star::uno::RuntimeException
));
134 // create a new module with the given name
135 void createModule(rtl::OUString
const & _aModule
) SAL_THROW((com::sun::star::uno::RuntimeException
));
137 virtual rtl::Reference
<CacheLine
> doCreateAttachedModule(sharable::TreeFragment
* _aLocation
, rtl::OUString
const & _aName
) SAL_THROW((com::sun::star::uno::RuntimeException
));
139 //-----------------------------------------------------------------------------
140 /** A collection of CacheLines
143 class ExtendedCacheData
: public CacheData
146 ExtendedCacheData() : CacheData()
150 /** add the given subtree at the given location,
151 return the tree that is now pertinent and clientAcquire() it once
153 sharable::TreeFragment
* addComponentData( backend::ComponentInstance
const & _aComponentInstance
,
155 ) SAL_THROW((com::sun::star::uno::RuntimeException
));
157 /// find the modules having pending changes
158 bool hasPending(rtl::OUString
const & _aModule
);
159 /// find the modules having pending changes
160 void findPendingModules( std::vector
< rtl::OUString
> & _rPendingList
);
162 /// add or merge the given subtreechange at the given location
163 void addPending(backend::ConstUpdateInstance
const & _anUpdate
) SAL_THROW((com::sun::star::uno::RuntimeException
));
164 /// remove and return pending changes for the given component
165 std::auto_ptr
<SubtreeChange
> releasePending(rtl::OUString
const & _aModule
) SAL_THROW((com::sun::star::uno::RuntimeException
));
167 // create a new module with the given name
168 void createModule(rtl::OUString
const & _aModule
) SAL_THROW((com::sun::star::uno::RuntimeException
));
170 virtual rtl::Reference
<CacheLine
> doCreateAttachedModule(sharable::TreeFragment
* _aLocation
, rtl::OUString
const & _aName
) SAL_THROW((com::sun::star::uno::RuntimeException
));
172 rtl::Reference
<ExtendedCacheLine
> implExtended(rtl::Reference
<CacheLine
> const & _aSimpleRef
) const;
174 //-----------------------------------------------------------------------------
176 } // namespace configmgr