#91896# New cache and backend interfaces

This commit is contained in:
Jörg Barfurth 2002-03-12 13:10:33 +00:00
parent a4dcde237a
commit 9160d72e10
7 changed files with 1323 additions and 0 deletions

View file

@ -0,0 +1,184 @@
/*************************************************************************
*
* $RCSfile: autoreferencemap.hxx,v $
*
* $Revision: 1.1 $
*
* last change: $Author: jb $ $Date: 2002-03-12 14:10:33 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2000 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library 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 for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2000 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#ifndef CONFIGMGR_AUTOREFERENCEMAP_HXX
#define CONFIGMGR_AUTOREFERENCEMAP_HXX
#ifndef _OSL_MUTEX_HXX_
#include <osl/mutex.hxx>
#endif
#ifndef _RTL_REF_HXX_
#include <rtl/ref.hxx>
#endif
#ifndef INCLUDED_MAP
#include <map>
#define INCLUDED_MAP
#endif
namespace configmgr
{
////////////////////////////////////////////////////////////////////////////////
using ::rtl::OUString;
//-----------------------------------------------------------------------------
template < class Key, class Object, class KeyCompare = std::less<Key> >
class AutoReferenceMap
{
public:
typedef rtl::Reference<Object> Ref;
typedef std::map<Key,Ref,KeyCompare> Map;
typedef Object object_type;
typedef Key key_type;
typedef KeyCompare key_compare;
typedef typename Map::value_type value_type;
public:
AutoReferenceMap() {}
~AutoReferenceMap() {}
void swap(Map & _rOtherData)
{
m_aMap.swap( _rOtherData );
}
void swap(AutoReferenceMap & _rOther)
{
this->swap( _rOther.m_aMap );
}
bool has(Key const & _aKey) const;
Ref getExisting(Key const & _aKey) const;
Ref getOrCreate(Key const & _aKey);
Ref remove(Key const & _aKey);
osl::Mutex & mutex() const { return m_aMutex; }
private:
Ref internalGet(Key const & _aKey) const
{
typename Map::const_iterator it = m_aMap.find(_aKey);
return it != m_aMap.end() ? it->second : Ref();
}
Ref internalNew(Key const & _aKey)
{
Ref aNewRef(new Object());
return m_aMap[_aKey] = aNewRef;
}
void internalDrop(Key const & _aKey)
{
m_aMap.erase(_aKey);
}
private:
mutable osl::Mutex m_aMutex;
Map m_aMap;
};
//-----------------------------------------------------------------------------
template < class Key, class Object, class KeyCompare >
bool AutoReferenceMap<Key,Object,KeyCompare>::has(Key const & _aKey) const
{
osl::MutexGuard aGuard(m_aMutex);
return internalGet(_aKey).is();
}
//-----------------------------------------------------------------------------
template < class Key, class Object, class KeyCompare >
rtl::Reference<Object> AutoReferenceMap<Key,Object,KeyCompare>::getExisting(Key const & _aKey) const
{
osl::MutexGuard aGuard(m_aMutex);
return internalGet(_aKey);
}
//-----------------------------------------------------------------------------
template < class Key, class Object, class KeyCompare >
rtl::Reference<Object> AutoReferenceMap<Key,Object,KeyCompare>::getOrCreate(Key const & _aKey)
{
osl::MutexGuard aGuard(m_aMutex);
Ref aRef = internalGet(_aKey);
if (!aRef.is())
aRef = internalNew(_aKey);
return aRef;
}
//-----------------------------------------------------------------------------
template < class Key, class Object, class KeyCompare >
rtl::Reference<Object> AutoReferenceMap<Key,Object,KeyCompare>::remove(Key const & _aKey)
{
osl::MutexGuard aGuard(m_aMutex);
Ref aRef = internalGet(_aKey);
internalDrop(_aKey);
return aRef;
}
//-----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
} // namespace configmgr
#endif

View file

@ -0,0 +1,277 @@
/*************************************************************************
*
* $RCSfile: cacheddataprovider.hxx,v $
*
* $Revision: 1.1 $
*
* last change: $Author: jb $ $Date: 2002-03-12 14:10:33 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2000 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library 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 for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2000 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
/* PLEASE DON'T DELETE ANY COMMENT LINES, ALSO IT'S UNNECESSARY. */
#ifndef CONFIGMGR_BACKEND_CACHEDDATAPROVIDER_HXX
#define CONFIGMGR_BACKEND_CACHEDDATAPROVIDER_HXX
#ifndef CONFIGMGR_BACKEND_REQUEST_HXX_
#include "request.hxx"
#endif
#ifndef CONFIGMGR_BACKEND_REQUESTTYPES_HXX_
#include "requesttypes.hxx"
#endif
#ifndef CONFIGMGR_SEGMENT_HXX
#include "segment.hxx"
#endif
#ifndef CONFIGMGR_UTILITY_HXX_
#include "utility.hxx"
#endif
#ifndef _SALHELPER_SIMPLEREFERENCEOBJECT_HXX_
#include <salhelper/simplereferenceobject.hxx>
#endif
#ifndef _RTL_REF_HXX_
#include <rtl/ref.hxx>
#endif
namespace configmgr
{
// ---------------------------------------------------------------------------
namespace backend
{
// ---------------------------------------------------------------------------
typedef memory::SegmentAddress CacheLocation;
typedef memory::SegmentID CacheLineID;
// ---------------------------------------------------------------------------
struct IDirectDataProvider;
struct ICachedDataNotifier;
// ---------------------------------------------------------------------------
/** Interface providing access to configuration data from some backend,
which is cached in a shared data cache.
*/
struct SAL_NO_VTABLE ICachedDataProvider
{
/** locates data of a component in the cache.
<p> If the data isn't in the cache it is loaded from the backend. </p>
<p> When the caller is done with the data, <method>freeComponent</method>
should be called. </p>
@param _aRequest
identifies the component to be loaded.
@returns
data that can be used to locate the loaded data in the cache.
@throws com::sun::star::uno::Exception
if loading the data fails.
The exact exception being thrown may depend on the underlying backend.
*/
virtual CacheLocation loadComponent(ComponentRequest const & _aRequest)
CFG_UNO_THROW_ALL() = 0;
/** releases data of a component from the cache.
<p> Should be called when a client is done with a component.
Each calls to <method>loadComponent</method> should
be balanced by exactly one call to <method>freeComponent</method>.
</p>
@param _aRequest
identifies a component previously loaded via <method>loadComponent</method>.
@returns
data that can be used to locate the loaded data in the cache.
*/
virtual void freeComponent(ComponentRequest const & _aRequest)
CFG_NOTHROW() = 0;
/** refreshes data of an existing component from the backend
<p> If the data is in the cache already, it is refreshed from the
backend and the change are notified to all registered listeners.
</p>
<p> If the data isn't in the cache nothing is done and
a NULL location is returned.
</p>
<p>Note: the caller <strong>must not</strong> hold any lock on the cache line affected.</p>
@param _aRequest
identifies the component to be refreshed.
@returns
data that can be used to locate the refreshed data in the cache.
<p>If there is no data to refresh a NULL location is returned.</p>
@throws com::sun::star::uno::Exception
if loading the data fails.
The exact exception being thrown may depend on the underlying backend.
*/
virtual CacheLocation refreshComponent(ComponentRequest const & _aRequest)
CFG_UNO_THROW_ALL() = 0;
/** locates a template in the cache.
<p> If the data isn't in the cache it is loaded from the backend. </p>
<p>Note: the caller <strong>must not</strong> hold any lock on the cache line affected.</p>
@param _aRequest
identifies the template to be loaded.
@returns
data that can be used to locate the template data in the cache.
@throws com::sun::star::uno::Exception
if loading the template data fails.
The exact exception being thrown may depend on the underlying backend.
*/
virtual CacheLocation loadTemplate(TemplateRequest const & _aRequest)
CFG_UNO_THROW_ALL() = 0;
/** saves changes to the backend and notifies them to registered listeners.
<p> Must be called after the changes have been applied to the cache
and before any subsequent changes to the same component.
</p>
<p> Notifications are guaranteed to be delivered
before any subsequent changes to the same component are possible.
</p>
<p> Note: the caller <strong>must</strong> hold a read lock (but no write lock)
on the cache line affected during the call.</p>
@param _anUpdate
identifies the node that changed and describes the changes.
@throws com::sun::star::uno::Exception
if saving the changes to the backend fails.
The exact exception being thrown may depend on the underlying backend.
*/
virtual void saveAndNotify(UpdateRequest const & _anUpdate)
CFG_UNO_THROW_ALL() = 0;
/** @returns
an object that can used to broadcast changes done through this object.
<p> The object returned is guaranteed to live as long
as this ICachedDataProvider lives.
</p>
*/
virtual ICachedDataNotifier & getNotifier() CFG_NOTHROW() = 0;
/** @returns
an object that can be used to retrieve owned copies of the data,
defaults and templates.
<p> The object returned is guaranteed to live as long
as this ICachedDataProvider lives.
</p>
*/
virtual IDirectDataProvider & getDirectDataProvider() CFG_NOTHROW() = 0;
};
// ---------------------------------------------------------------------------
/** Listener interface for observing changes in the cache
managed by a <type>ICachedDataProvider</type>
*/
struct SAL_NO_VTABLE ICachedDataListener : Refcounted
{
/// is called when the provider is closing down
virtual void disposing(ICachedDataProvider & _rProvider) CFG_NOTHROW() = 0;
/// is called when a new component was loaded into the cache.
virtual void componentCreated(ComponentRequest const & _aComponent) CFG_NOTHROW() = 0;
/// is called when data of an already loaded component changed in the cache.
virtual void componentChanged(UpdateRequest const & _anUpdate) CFG_NOTHROW() = 0;
};
// ---------------------------------------------------------------------------
/** Interface providing a multicasting service for changes to the cache
managed by a <type>ICachedDataProvider</type>
*/
struct SAL_NO_VTABLE ICachedDataNotifier
{
// firing notifications.
/// notify all registered listeners and close down this notifier
virtual void dispose(ICachedDataProvider & _rProvider) CFG_NOTHROW() = 0;
/** notify a new component to all registered listeners.
<p> Must be called after the component has been created in the cache.</p>
*/
virtual void notifyCreated(ComponentRequest const & _aComponent) CFG_NOTHROW() = 0;
/** notify changed data to all registered listeners.
<p> Must be called after the change has been applied to the cache
and before any subsequent changes to the same component.</p>
*/
virtual void notifyChanged(UpdateRequest const & _anUpdate) CFG_NOTHROW() = 0;
// listener registration.
typedef rtl::Reference<ICachedDataListener> ListenerRef;
/// register a listener for observing changes to the cached data
virtual void addListener(ListenerRef _xListener) CFG_NOTHROW() = 0;
/// unregister a listener previously registered
virtual void removeListener(ListenerRef _xListener) CFG_NOTHROW() = 0;
};
// ---------------------------------------------------------------------------
} // namespace backend
// ---------------------------------------------------------------------------
} // namespace configmgr
#endif

View file

@ -0,0 +1,88 @@
/*************************************************************************
*
* $RCSfile: cachefactory.hxx,v $
*
* $Revision: 1.1 $
*
* last change: $Author: jb $ $Date: 2002-03-12 14:10:33 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2000 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library 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 for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2000 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#ifndef CONFIGMGR_CACHEFACTORY_HXX_
#define CONFIGMGR_CACHEFACTORY_HXX_
#ifndef _RTL_REF_HXX_
#include <rtl/ref.hxx>
#endif
namespace configmgr
{
//-----------------------------------------------------------------------------
class TreeManager;
class IConfigSession;
class OOptions;
//-----------------------------------------------------------------------------
struct CacheFactory
{
rtl::Reference<TreeManager>
createCacheManager(IConfigSession * pSession, OOptions const & _rOptions);
static CacheFactory & instance();
};
//-----------------------------------------------------------------------------
}
#endif // CONFIGMGR_CACHEFACTORY_HXX_

View file

@ -0,0 +1,265 @@
/*************************************************************************
*
* $RCSfile: mergeddataprovider.hxx,v $
*
* $Revision: 1.1 $
*
* last change: $Author: jb $ $Date: 2002-03-12 14:10:33 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2000 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library 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 for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2000 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#ifndef CONFIGMGR_BACKEND_MERGEDDATAPROVIDER_HXX
#define CONFIGMGR_BACKEND_MERGEDDATAPROVIDER_HXX
#ifndef CONFIGMGR_BACKEND_REQUEST_HXX_
#include "request.hxx"
#endif
#ifndef CONFIGMGR_BACKEND_REQUESTTYPES_HXX_
#include "requesttypes.hxx"
#endif
#ifndef CONFIGMGR_UTILITY_HXX_
#include "utility.hxx"
#endif
namespace configmgr
{
// ---------------------------------------------------------------------------
namespace backend
{
// ---------------------------------------------------------------------------
/** Listener interface for receiving notifications
about changes to previously requested data
*/
struct INodeDataListener : Refcounted
{
/** is called to indicate changes within the data being observed.
@param _aOriginalRequest
identifies the data that changed
*/
virtual void dataChanged(NodeRequest const & _aOriginalRequest) CFG_NOTHROW() = 0;
};
// ---------------------------------------------------------------------------
/// Interface providing access to (merged) data for whole components
struct IComponentDataProvider
{
/** loads merged data for a (complete) tree and returns it as return value.
@param _aRequest
identifies the component to be loaded
@returns
A valid node instance for the given component.
@throws com::sun::star::uno::Exception
if the node cannot be retrieved.
The exact exception being thrown may depend on the underlying backend.
*/
virtual NodeInstance getComponentData(ComponentRequest const & _aRequest)
CFG_UNO_THROW_ALL() = 0;
};
// ---------------------------------------------------------------------------
/** Interface providing access to (merged) data for individual nodes
with optional notification about subsequent changes.
There is no guarantee, that all changes are notified immediately
(or even at all).If the provider cannot detect changes
it may simply ignore a supplied listener.
*/
struct INodeDataProvider
{
/** loads merged data for a (partial) tree and returns it as return value.
@param _aRequest
identifies the node to be loaded
@param _pListener
a listener to observe subsequent changes to the data requested
<p> If NULL, no notifications will be sent. </p>
<p> Otherwise the listener will be notified of changes.
The listener must subsequently be removed by calling
<member>INodeDataProvider::removeRequestListener</member>.
The listener must live at least until it is removed.
</p>
@returns
A valid node instance for the given request.
@throws com::sun::star::uno::Exception
if the node cannot be retrieved.
The exact exception being thrown may depend on the underlying backend.
*/
virtual NodeInstance getNodeData(NodeRequest const & _aRequest, INodeDataListener * _pListener = NULL)
CFG_UNO_THROW_ALL() = 0;
/** remove a listener registered for a previous request.
<p>This may also release some open resources for the request.</p>
@param _pListener
a listener that was passed to a previous succes
*/
virtual void removeRequestListener(INodeDataListener * _pListener) CFG_NOTHROW() = 0;
};
// ---------------------------------------------------------------------------
/// Interface providing the capability to update node data
struct INodeUpdateProvider
{
/** applies an update to the stored data.
@param _anUpdate
identifies the node to be updated and
describes the changes to be applied.
@throws com::sun::star::uno::Exception
if the node cannot be updated.
The exact exception being thrown may depend on the underlying backend.
*/
virtual void updateNodeData(UpdateRequest const & _anUpdate)
CFG_UNO_THROW_ALL() = 0;
};
// ---------------------------------------------------------------------------
/// Interface providing access to (merged) default data
struct IDefaultDataProvider
{
/** loads default data for a (partial) tree and returns it as return value
@param _aRequest
identifies the node to be loaded
@returns
A valid node instance for the default state of the given node.
<p>May be NULL, if the node exists but has no default equivalent.</p>
@throws com::sun::star::uno::Exception
if the default cannot be retrieved.
The exact exception being thrown may depend on the underlying backend.
*/
virtual NodeInstance getDefaultData(NodeRequest const & _aRequest)
CFG_UNO_THROW_ALL() = 0;
};
// ---------------------------------------------------------------------------
/// Interface providing access to template (schema) data
struct ITemplateDataProvider
{
/** loads a given template and returns it as return value
@param _aRequest
identifies the template to be loaded
@returns
A valid instance of the given template.
<p> Currently a request with empty template name
will retrieve a group node holding all templates
of a component.
</p>
@throws com::sun::star::uno::Exception
if the template cannot be retrieved.
The exact exception being thrown may depend on the underlying backend.
*/
virtual TemplateInstance getTemplateData(TemplateRequest const & _aRequest)
CFG_UNO_THROW_ALL() = 0;
};
// ---------------------------------------------------------------------------
/** Composite interface providing simple direct access to (merged) configuration data
from some data store.
<p> Only loading data is supported (no updates or notifications). </p>
*/
struct IDirectDataProvider
: Refcounted
, IComponentDataProvider
, IDefaultDataProvider
, ITemplateDataProvider
{
};
// ---------------------------------------------------------------------------
/** Composite interface providing full access to merged configuration data
from some data store.
<p> Loading and updating of data is supported.
Support for notification depends on the backend.
</p>
*/
struct IMergedDataProvider
: Refcounted
, INodeDataProvider
, INodeUpdateProvider
, IDefaultDataProvider
, ITemplateDataProvider
{
};
// ---------------------------------------------------------------------------
} // namespace backend
// ---------------------------------------------------------------------------
} // namespace configmgr
#endif

View file

@ -0,0 +1,182 @@
/*************************************************************************
*
* $RCSfile: request.hxx,v $
*
* $Revision: 1.1 $
*
* last change: $Author: jb $ $Date: 2002-03-12 14:10:33 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2000 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library 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 for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2000 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#ifndef CONFIGMGR_BACKEND_REQUEST_HXX_
#define CONFIGMGR_BACKEND_REQUEST_HXX_
#ifndef CONFIGMGR_MISC_REQUESTOPTIONS_HXX_
#include "requestoptions.hxx"
#endif
#ifndef CONFIGMGR_BACKEND_REQUESTTYPES_HXX_
#include "requesttypes.hxx"
#endif
#ifndef CONFIGMGR_CONFIGPATH_HXX_
#include "configpath.hxx"
#endif
namespace configmgr
{
// ---------------------------------------------------------------------------
namespace backend
{
// ---------------------------------------------------------------------------
using configuration::AbsolutePath;
using configuration::Name;
// ---------------------------------------------------------------------------
class NodeRequest
{
AbsolutePath m_aNodePath;
RequestOptions m_aOptions;
public:
NodeRequest(AbsolutePath const& _aNodePath, RequestOptions const & _aOptions)
: m_aNodePath(_aNodePath)
, m_aOptions(_aOptions)
{
}
AbsolutePath const & getPath() const { return m_aNodePath; }
RequestOptions const & getOptions() const { return m_aOptions; }
};
// ---------------------------------------------------------------------------
class ComponentRequest
{
Name m_aComponentName;
RequestOptions m_aOptions;
public:
ComponentRequest(Name const& _aComponentName, RequestOptions const & _aOptions)
: m_aComponentName(_aComponentName)
, m_aOptions(_aOptions)
{
}
Name const & getComponentName() const { return m_aComponentName; }
RequestOptions const & getOptions() const { return m_aOptions; }
};
// ---------------------------------------------------------------------------
class TemplateRequest
{
Name m_aComponentName;
Name m_aTemplateName;
public:
explicit
TemplateRequest(Name const & _aComponentName)
: m_aComponentName(_aComponentName)
, m_aTemplateName()
{}
explicit
TemplateRequest(Name const & _aComponentName, Name const & _aTemplateName)
: m_aComponentName(_aComponentName)
, m_aTemplateName(_aTemplateName)
{}
bool isComponentRequest() const { return m_aTemplateName.isEmpty(); }
Name getTemplateName() const { return m_aTemplateName; }
Name getComponentName() const { return m_aComponentName; }
static RequestOptions getOptions();
};
inline ComponentRequest getComponentRequest(TemplateRequest const & _aTR)
{ return ComponentRequest(_aTR.getComponentName(), _aTR.getOptions()); }
// ---------------------------------------------------------------------------
class UpdateRequest
{
UpdateInstance m_aUpdate;
RequestOptions m_aOptions;
bool m_bForceFlush;
public:
explicit
UpdateRequest(UpdateInstance & _aUpdate, RequestOptions const & _aOptions)
: m_aUpdate(_aUpdate)
, m_aOptions(_aOptions)
, m_bForceFlush( _aOptions.isForcingReload() )
{}
explicit
UpdateRequest(AbsolutePath const & _aRootpath, UpdateInstance::Data & _aUpdateData, RequestOptions const & _aOptions)
: m_aUpdate(_aRootpath,_aUpdateData)
, m_aOptions(_aOptions)
, m_bForceFlush( _aOptions.isForcingReload() )
{}
void forceFlush() { m_bForceFlush = true; }
bool isForcingFlush() const { return m_bForceFlush; }
UpdateInstance const & getUpdate() const { return m_aUpdate; }
RequestOptions const & getOptions() const { return m_aOptions; }
};
inline ComponentRequest getComponentRequest(UpdateRequest const & _aUR)
{ return ComponentRequest(_aUR.getUpdate().root.getModuleName(), _aUR.getOptions()); }
// ---------------------------------------------------------------------------
} // namespace
// ---------------------------------------------------------------------------
} // namespace
#endif

View file

@ -0,0 +1,173 @@
/*************************************************************************
*
* $RCSfile: requestoptions.hxx,v $
*
* $Revision: 1.1 $
*
* last change: $Author: jb $ $Date: 2002-03-12 14:10:33 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2000 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library 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 for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2000 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#ifndef CONFIGMGR_MISC_REQUESTOPTIONS_HXX_
#define CONFIGMGR_MISC_REQUESTOPTIONS_HXX_
#ifndef _RTL_USTRING_HXX_
#include <rtl/ustring.hxx>
#endif
namespace configmgr
{
// ---------------------------------------------------------------------------
/**
Options which can be used to modify a request for data
*/
class RequestOptions
{
public:
typedef rtl::OUString Locale;
typedef rtl::OUString Entity;
public:
/// Default constructor. Sets options to use defaults.
RequestOptions()
: m_sLocale()
, m_sEntity()
, m_nCacheID(0)
{}
/// Copy constructor. Copies all options (optionally copying or renewing the cache ID)
RequestOptions(const RequestOptions& _aOther, bool _bRenewCacheID = false)
: m_sLocale(_aOther.m_sLocale)
, m_sEntity(_aOther.m_sEntity)
{
if (_bRenewCacheID)
{
m_nCacheID = 0;
this->forceReload(_aOther.isForcingReload());
}
else
{
m_nCacheID = _aOther.m_nCacheID;
}
}
/// @returns <TRUE/>, if data must be loaded freshly into a private cache line
bool isForcingReload() const { return m_nCacheID != 0; }
/// @returns an ID number identifying the private cache line to use
sal_Int32 getCacheID() const { return m_nCacheID; }
/** @returns
<TRUE/>, if a locale is specified, <BR/>
<FALSE/>, if the default locale should be used
*/
bool hasLocale() const { return m_sLocale.getLength() != 0; }
/// @returns the locale to get data for
Locale getLocale() const { return m_sLocale; }
/** @returns
<TRUE/>, if an entity is specified, <BR/>
<FALSE/>, if data of the session user is requested
*/
bool hasEntity() const { return m_sEntity.getLength() != 0; }
/// @returns the entity to get data for
Entity getEntity() const { return m_sEntity; }
/// sets the entity to get data for to the given entity
void setEntity(Entity const & _sEntity) { m_sEntity = _sEntity; }
/// resets the entity to get data for to be the session user
void clearEntity() { m_sEntity = rtl::OUString(); }
/// sets the locale so data is gotten for all locales
void setAllLocales();
/// sets the locale to get data for to the given locale
void setLocale(Locale const & _sLocale) { m_sLocale = _sLocale; }
/// resets the locale to get data for to use the default
void clearLocale() { m_sLocale = rtl::OUString(); }
/// forces data to be freshly loaded into a new private cache line
void forceReload(bool _bNoCache = true);
// comparison/container helpers
/// return a hash code for this object
sal_Int32 hashCode() const;
/// function that defines a weak strict ordering on RequestOptions
friend sal_Int32 compareRequestOptions(RequestOptions const& lhs, RequestOptions const& rhs);
private:
Locale m_sLocale; /// locale to fetch data for
Entity m_sEntity; /// user/group/role to fetch data for
sal_Int32 m_nCacheID; /// nonzero, if data should not be fetched from the cache, but reloaded
};
// ---------------------------------------------------------------------------
struct lessRequestOptions
{
bool operator()(RequestOptions const & lhs, RequestOptions const & rhs) const
{ return compareRequestOptions(lhs,rhs) < 0; }
};
// ---------------------------------------------------------------------------
struct equalRequestOptions
{
bool operator()(RequestOptions const & lhs, RequestOptions const & rhs) const
{ return compareRequestOptions(lhs,rhs) == 0; }
};
// ---------------------------------------------------------------------------
struct hashRequestOptions
{
sal_Int32 operator()(RequestOptions const & _opt) const
{ return _opt.hashCode(); }
};
// ---------------------------------------------------------------------------
} // namespace
#endif

View file

@ -0,0 +1,154 @@
/*************************************************************************
*
* $RCSfile: requesttypes.hxx,v $
*
* $Revision: 1.1 $
*
* last change: $Author: jb $ $Date: 2002-03-12 14:10:33 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2000 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library 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 for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2000 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#ifndef CONFIGMGR_BACKEND_REQUESTTYPES_HXX_
#define CONFIGMGR_BACKEND_REQUESTTYPES_HXX_
#ifndef _CONFIGMGR_TREE_VALUENODE_HXX
#include "valuenode.hxx"
#endif
#ifndef CONFIGMGR_TREECHANGELIST_HXX
#include "treechangelist.hxx"
#endif
#ifndef CONFIGMGR_CONFIGPATH_HXX_
#include "configpath.hxx"
#endif
#ifndef INCLUDED_MEMORY
#include <memory>
#define INCLUDED_MEMORY
#endif
namespace configmgr
{
// ---------------------------------------------------------------------------
namespace backend
{
// ---------------------------------------------------------------------------
using configuration::AbsolutePath;
using configuration::Name;
// ---------------------------------------------------------------------------
class NodePath
{
AbsolutePath m_path;
public:
NodePath(AbsolutePath const & _path) : m_path(_path) {};
AbsolutePath const & location() const { return m_path; }
AbsolutePath context() const { return m_path.getParentPath(); }
bool isEmpty() const { return m_path.isRoot(); }
bool isModuleRoot() const { return m_path.getDepth() == 1; }
Name getModuleName() const { return m_path.getModuleName(); }
rtl::OUString toString() const { return m_path.toString(); }
};
// ---------------------------------------------------------------------------
struct NodeInstance
{
typedef std::auto_ptr<ISubtree> Data;
explicit
NodeInstance(AbsolutePath const & _rootpath, Data & _node)
: node(_node)
, root(_rootpath)
{
}
Data node;
NodePath root;
};
// ---------------------------------------------------------------------------
struct TemplateInstance
{
typedef std::auto_ptr<INode> Data;
explicit
TemplateInstance(Data & _node, Name const & _component)
: node(_node)
, component(_component)
{
}
Data node;
Name name; // if empty, this is a complete set of component templates
Name component;
};
// ---------------------------------------------------------------------------
struct UpdateInstance
{
typedef std::auto_ptr<SubtreeChange> Data;
explicit
UpdateInstance(AbsolutePath const & _rootpath, Data & _update)
: update(_update)
, root(_rootpath)
{
}
Data update;
NodePath root;
};
// ---------------------------------------------------------------------------
}
// ---------------------------------------------------------------------------
} // namespace
#endif