2002-03-15 04:50:25 -06:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2008-04-11 07:37:44 -05:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
2002-03-15 04:50:25 -06:00
|
|
|
*
|
2008-04-11 07:37:44 -05:00
|
|
|
* Copyright 2008 by Sun Microsystems, Inc.
|
2002-03-15 04:50:25 -06:00
|
|
|
*
|
2008-04-11 07:37:44 -05:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2002-03-15 04:50:25 -06:00
|
|
|
*
|
2008-04-11 07:37:44 -05:00
|
|
|
* $RCSfile: cachedata.hxx,v $
|
|
|
|
* $Revision: 1.9 $
|
2002-03-15 04:50:25 -06:00
|
|
|
*
|
2008-04-11 07:37:44 -05:00
|
|
|
* This file is part of OpenOffice.org.
|
2002-03-15 04:50:25 -06:00
|
|
|
*
|
2008-04-11 07:37:44 -05:00
|
|
|
* OpenOffice.org is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Lesser General Public License version 3
|
|
|
|
* only, as published by the Free Software Foundation.
|
2002-03-15 04:50:25 -06:00
|
|
|
*
|
2008-04-11 07:37:44 -05:00
|
|
|
* OpenOffice.org is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Lesser General Public License version 3 for more details
|
|
|
|
* (a copy is included in the LICENSE file that accompanied this code).
|
2002-03-15 04:50:25 -06:00
|
|
|
*
|
2008-04-11 07:37:44 -05:00
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
|
|
* version 3 along with OpenOffice.org. If not, see
|
|
|
|
* <http://www.openoffice.org/license.html>
|
|
|
|
* for a copy of the LGPLv3 License.
|
2002-03-15 04:50:25 -06:00
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
|
|
|
|
#ifndef CONFIGMGR_CACHEDATA_HXX
|
|
|
|
#define CONFIGMGR_CACHEDATA_HXX
|
|
|
|
|
|
|
|
#include "cacheline.hxx"
|
|
|
|
|
|
|
|
#ifndef INCLUDED_MAP
|
|
|
|
#include <map>
|
|
|
|
#define INCLUDED_MAP
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef INCLUDED_VECTOR
|
|
|
|
#include <vector>
|
|
|
|
#define INCLUDED_VECTOR
|
|
|
|
#endif
|
|
|
|
|
|
|
|
namespace configmgr
|
|
|
|
{
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
using ::rtl::OUString;
|
|
|
|
|
|
|
|
namespace backend
|
|
|
|
{
|
|
|
|
struct NodeInstance;
|
|
|
|
struct TemplateInstance;
|
|
|
|
struct UpdateInstance;
|
2002-03-28 02:08:05 -06:00
|
|
|
struct ConstUpdateInstance;
|
2002-03-15 04:50:25 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
/** A collection of CacheLines
|
|
|
|
*/
|
|
|
|
|
|
|
|
class CacheData
|
|
|
|
{
|
|
|
|
public:
|
2007-11-23 07:35:48 -06:00
|
|
|
CacheData();
|
2004-03-23 03:30:25 -06:00
|
|
|
virtual ~CacheData();
|
2002-03-15 04:50:25 -06:00
|
|
|
|
|
|
|
/// retrieve the module tree name for the given path
|
2007-11-23 07:35:48 -06:00
|
|
|
static CacheLine::Name extractModuleName(CacheLine::Path const& _aPath);
|
2002-03-15 04:50:25 -06:00
|
|
|
|
2007-11-23 07:35:48 -06:00
|
|
|
// attach a module with a given name
|
|
|
|
void attachModule(data::TreeAddress _aLocation, CacheLine::Name const & _aModule);
|
2002-03-15 04:50:25 -06:00
|
|
|
/// check if the given module exists already (and is not empty)
|
2007-11-23 07:35:48 -06:00
|
|
|
bool hasModule(CacheLine::Name const & _aModule) const;
|
2002-03-28 02:08:05 -06:00
|
|
|
/// checks if the given module exists and has defaults available
|
2007-11-23 07:35:48 -06:00
|
|
|
bool hasModuleDefaults(CacheLine::Name const & _aModule) const;
|
2002-03-15 04:50:25 -06:00
|
|
|
|
2007-11-23 07:35:48 -06:00
|
|
|
/// gets a tree address for the given module if it exists
|
|
|
|
data::TreeAddress getTreeAddress(CacheLine::Name const & _aModule) const;
|
2002-03-15 04:50:25 -06:00
|
|
|
|
|
|
|
/// checks whether a certain node exists in the tree
|
2007-11-23 07:35:48 -06:00
|
|
|
bool hasNode(CacheLine::Path const & _aLocation) const;
|
2002-03-15 04:50:25 -06:00
|
|
|
|
|
|
|
/// retrieve the given node without changing its ref count
|
2007-11-23 07:35:48 -06:00
|
|
|
data::NodeAddress getNode(CacheLine::Path const & _rPath);
|
2002-03-15 04:50:25 -06:00
|
|
|
/// retrieve the given template tree without changing its ref count
|
2007-11-23 07:35:48 -06:00
|
|
|
data::TreeAddress getTemplateTree( CacheLine::Path const & aTemplateName ) const;
|
2002-03-15 04:50:25 -06:00
|
|
|
|
|
|
|
/// retrieve the subtree at _aPath and clientAcquire() it
|
2007-11-23 07:35:48 -06:00
|
|
|
data::NodeAddress acquireNode(CacheLine::Path const & _aPath );
|
|
|
|
/// retrieve the subtree at _aPath and clientAcquire() it, return true on success
|
|
|
|
bool acquireModule( CacheLine::Name const & _aModule );
|
2002-03-15 04:50:25 -06:00
|
|
|
/// clientRelease() the tree at aComponentName, and return the resulting reference count
|
2007-11-23 07:35:48 -06:00
|
|
|
oslInterlockedCount releaseModule( CacheLine::Name const & _aModule, bool _bKeepDeadModule = false );
|
2002-03-15 04:50:25 -06:00
|
|
|
|
2007-11-23 07:35:48 -06:00
|
|
|
bool insertDefaults( backend::NodeInstance const & _aDefaultInstance
|
2002-03-15 04:50:25 -06:00
|
|
|
) CFG_UNO_THROW_RTE();
|
|
|
|
|
|
|
|
/// merge the given changes into this tree - reflects old values to _anUpdate
|
2007-11-23 07:35:48 -06:00
|
|
|
void applyUpdate( backend::UpdateInstance & _anUpdate) CFG_UNO_THROW_RTE( );
|
2002-03-15 04:50:25 -06:00
|
|
|
|
|
|
|
// low-level interface for cache management
|
2007-11-23 07:35:48 -06:00
|
|
|
typedef std::map<CacheLine::Name, CacheLineRef> ModuleList;
|
2002-03-15 04:50:25 -06:00
|
|
|
ModuleList& accessModuleList() { return m_aModules; }
|
2002-03-28 02:08:05 -06:00
|
|
|
|
2002-03-15 04:50:25 -06:00
|
|
|
protected:
|
2007-11-23 07:35:48 -06:00
|
|
|
virtual CacheLineRef doCreateAttachedModule(data::TreeAddress _aLocation, const CacheLine::Name& _aName) CFG_UNO_THROW_RTE( );
|
2002-03-15 04:50:25 -06:00
|
|
|
|
2007-11-23 07:35:48 -06:00
|
|
|
data::TreeAddress internalGetPartialTree(CacheLine::Path const & _aPath ) const;
|
|
|
|
data::NodeAddress internalGetNode(const CacheLine::Path& _rPath) const;
|
2002-03-15 04:50:25 -06:00
|
|
|
|
2007-11-23 07:35:48 -06:00
|
|
|
CacheLineRef internalAttachModule(data::TreeAddress _aLocation, const CacheLine::Name& _aName) CFG_UNO_THROW_RTE( );
|
|
|
|
void internalAddModule(CacheLine::Name const & _aName, CacheLineRef const & _aModule);
|
2002-03-15 04:50:25 -06:00
|
|
|
|
2007-11-23 07:35:48 -06:00
|
|
|
CacheLineRef internalGetModule(const CacheLine::Name& _aName) const;
|
|
|
|
CacheLineRef internalGetModule(const CacheLine::Path& _aLocation) const;
|
2002-03-15 04:50:25 -06:00
|
|
|
|
|
|
|
private:
|
|
|
|
ModuleList m_aModules;
|
|
|
|
};
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
/** A collection of CacheLines for templates
|
|
|
|
*/
|
|
|
|
|
|
|
|
class TemplateCacheData : public CacheData
|
|
|
|
{
|
|
|
|
public:
|
2007-11-23 07:35:48 -06:00
|
|
|
TemplateCacheData() : CacheData()
|
2002-03-15 04:50:25 -06:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/** add the given template tree at the given location,
|
|
|
|
return the tree that is now pertinent and clientAcquire() it once
|
|
|
|
*/
|
2007-11-23 07:35:48 -06:00
|
|
|
data::TreeAddress addTemplates( backend::ComponentData const & _aComponentInstance
|
2002-03-15 04:50:25 -06:00
|
|
|
) CFG_UNO_THROW_RTE();
|
|
|
|
|
2007-11-23 07:35:48 -06:00
|
|
|
// create a new module with the given name
|
|
|
|
void createModule(CacheLine::Name const & _aModule) CFG_UNO_THROW_RTE();
|
2002-03-15 04:50:25 -06:00
|
|
|
private:
|
2007-11-23 07:35:48 -06:00
|
|
|
virtual CacheLineRef doCreateAttachedModule(data::TreeAddress _aLocation, const CacheLine::Name& _aName) CFG_UNO_THROW_RTE( );
|
2002-03-15 04:50:25 -06:00
|
|
|
};
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
/** A collection of CacheLines
|
|
|
|
*/
|
|
|
|
|
|
|
|
class ExtendedCacheData : public CacheData
|
|
|
|
{
|
|
|
|
public:
|
2007-11-23 07:35:48 -06:00
|
|
|
ExtendedCacheData() : CacheData()
|
2002-03-15 04:50:25 -06:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/** add the given subtree at the given location,
|
|
|
|
return the tree that is now pertinent and clientAcquire() it once
|
|
|
|
*/
|
2007-11-23 07:35:48 -06:00
|
|
|
data::TreeAddress addComponentData( backend::ComponentInstance const & _aComponentInstance,
|
2002-03-15 04:50:25 -06:00
|
|
|
bool _bWithDefaults
|
|
|
|
) CFG_UNO_THROW_RTE();
|
|
|
|
|
2007-11-23 07:35:48 -06:00
|
|
|
typedef std::vector< CacheLine::Name > PendingModuleList;
|
|
|
|
|
2002-03-15 04:50:25 -06:00
|
|
|
/// find the modules having pending changes
|
2007-11-23 07:35:48 -06:00
|
|
|
bool hasPending(CacheLine::Name const & _aModule);
|
2002-03-28 02:08:05 -06:00
|
|
|
/// find the modules having pending changes
|
2002-03-15 04:50:25 -06:00
|
|
|
void findPendingModules( PendingModuleList & _rPendingList );
|
|
|
|
|
|
|
|
/// add or merge the given subtreechange at the given location
|
2002-03-28 02:08:05 -06:00
|
|
|
void addPending(backend::ConstUpdateInstance const & _anUpdate) CFG_UNO_THROW_RTE( );
|
2002-03-15 04:50:25 -06:00
|
|
|
/// remove and return pending changes for the given component
|
2007-11-23 07:35:48 -06:00
|
|
|
std::auto_ptr<SubtreeChange> releasePending(CacheLine::Name const & _aModule) CFG_UNO_THROW_RTE( );
|
2002-03-15 04:50:25 -06:00
|
|
|
|
2007-11-23 07:35:48 -06:00
|
|
|
// create a new module with the given name
|
|
|
|
void createModule(CacheLine::Name const & _aModule) CFG_UNO_THROW_RTE();
|
|
|
|
private:
|
|
|
|
virtual CacheLineRef doCreateAttachedModule(data::TreeAddress _aLocation, const CacheLine::Name& _aName) CFG_UNO_THROW_RTE( );
|
2002-03-15 04:50:25 -06:00
|
|
|
|
2007-11-23 07:35:48 -06:00
|
|
|
ExtendedCacheLineRef implExtended(CacheLineRef const & _aSimpleRef) const;
|
2002-03-15 04:50:25 -06:00
|
|
|
};
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
} // namespace configmgr
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|