Kaydet (Commit) 0fddb290 authored tarafından Ivo Hinkelmann's avatar Ivo Hinkelmann

INTEGRATION: CWS configrefactor01 (1.6.14); FILE MERGED

2007/10/05 14:14:05 mmeeks 1.6.14.3: Issue number: i#82311
Submitted by: mmeeks
Reviewed by:  mmeeks

Cleanups from patch re-review.
Improvements to unit-testing framework.
2007/01/11 10:35:31 mmeeks 1.6.14.2: Submitted by: mmeeks

Large scale re-factoring, remove fine-grained locking in favor of a simple,
single global lock (still in progress).
Identify and fix various hot-spots.
Remove otherwise empty / non-compiled files.
Kill UpdateAccessor
2007/01/08 20:48:56 mmeeks 1.6.14.1: Issue number:
Submitted by: mmeeks
Substantial configmgr re-factoring #1 ...
	+ remove endless typedef chains
	+ remove custom allocator & associated complexity
	+ remove Pointer, and 'Address' classes
üst 0bc16bc3
...@@ -4,9 +4,9 @@ ...@@ -4,9 +4,9 @@
* *
* $RCSfile: treeaccessor.hxx,v $ * $RCSfile: treeaccessor.hxx,v $
* *
* $Revision: 1.6 $ * $Revision: 1.7 $
* *
* last change: $Author: kz $ $Date: 2006-11-06 14:48:46 $ * last change: $Author: ihi $ $Date: 2007-11-23 14:25:13 $
* *
* The Contents of this file are made available subject to * The Contents of this file are made available subject to
* the terms of GNU Lesser General Public License Version 2.1. * the terms of GNU Lesser General Public License Version 2.1.
...@@ -36,109 +36,61 @@ ...@@ -36,109 +36,61 @@
#ifndef CONFIGMGR_TREEACCESSOR_HXX #ifndef CONFIGMGR_TREEACCESSOR_HXX
#define CONFIGMGR_TREEACCESSOR_HXX #define CONFIGMGR_TREEACCESSOR_HXX
#ifndef CONFIGMGR_TREEADDRESS_HXX
#include "treeaddress.hxx"
#endif
#ifndef CONFIGMGR_ACCESSOR_HXX
#include "accessor.hxx"
#endif
#ifndef CONFIGMGR_NODEACCESS_HXX #ifndef CONFIGMGR_NODEACCESS_HXX
#include "nodeaccess.hxx" #include "nodeaccess.hxx"
#endif #endif
#ifndef INCLUDED_SHARABLE_TREEFRAGMENT_HXX
#include "treefragment.hxx"
#endif
#ifndef INCLUDED_CSTDDEF #ifndef INCLUDED_CSTDDEF
#include <cstddef> #include <cstddef>
#define INCLUDED_CSTDDEF #define INCLUDED_CSTDDEF
#endif #endif
#ifndef CONFIGMGR_BUILDDATA_HXX
#include <builddata.hxx>
#endif
namespace configmgr namespace configmgr
{ {
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
namespace memory { class UpdateAccessor; }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
namespace data namespace data
{ {
// -------------------------------------------------------------------------
using memory::Accessor;
// -------------------------------------------------------------------------
class ValueNodeAccess;
class GroupNodeAccess;
class SetNodeAccess;
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
/** class that mediates access to the data of a tree fragment /** class that mediates access to the data of a tree fragment
*/ */
class TreeAccessor class TreeAccessor
{ {
public: public:
typedef configuration::Name Name; TreeAccessor(sharable::TreeFragment *_aTreeRef)
typedef node::Attributes Attributes; : m_pTree(_aTreeRef) {}
typedef TreeAddress DataAddressType; TreeAccessor(const sharable::TreeFragment * _pTree)
typedef TreeAddress::DataType const DataType; : m_pTree((sharable::TreeFragment *)_pTree) {}
typedef DataType * DataPointerType;
static TreeAccessor emptyTree() { return TreeAccessor(); }
TreeAccessor(Accessor const& _aAccessor, DataAddressType const& _aTreeRef)
: m_aAccessor(_aAccessor)
, m_pBase(_aTreeRef.m_pData)
{}
TreeAccessor(Accessor const& _aAccessor, DataPointerType _pTree)
: m_aAccessor(_aAccessor)
, m_pBase(_aAccessor.address(_pTree))
{}
bool isValid() const { return m_pBase.is(); }
bool isDefault() const { return data().isDefault(); }
Attributes getAttributes() const { return data().getAttributes(); } inline configuration::Name getName() const
Name getName() const; { return configuration::makeName( m_pTree->getName(),
configuration::Name::NoValidate() ); }
NodeAccessRef getRootNode() const { return NodeAccessRef(&m_aAccessor,rootAddress(m_pBase)); } NodeAccess getRootNode() const
{ return NodeAccess(m_pTree ? const_cast<sharable::Node *>(m_pTree->nodes) : NULL); }
DataAddressType address() const { return m_pBase; } TreeAddress copyTree() const
Accessor const& accessor() const { return m_aAccessor; } { return data::buildTree(*this); }
static void freeTree(TreeAddress _aTree)
{ data::destroyTree(_aTree); }
DataType& data() const { return *static_cast<DataPointerType>(m_aAccessor.validate(m_pBase.m_pData)); } // make it look like a pointer ...
DataPointerType getDataPtr() const { return access(m_pBase,m_aAccessor); } operator sharable::TreeFragment *() const { return (sharable::TreeFragment *)m_pTree; }
sharable::TreeFragment* operator->() const { return m_pTree; }
bool operator == (sharable::TreeFragment *pTree) const { return pTree == m_pTree; }
bool operator != (sharable::TreeFragment *pTree) const { return pTree != m_pTree; }
TreeAddress copyTree(memory::UpdateAccessor & _aTargetSpace) const;
static void freeTree(memory::UpdateAccessor & _aTargetSpace, TreeAddress _aTree);
static Name wrapName(rtl::OUString const& _aNameString)
{ return configuration::makeName( _aNameString, Name::NoValidate() ); }
static TreeAddress::DataType* access(DataAddressType const& _aTreeRef, memory::UpdateAccessor& _rUpdateAccess);
static TreeAddress::DataType const* access(DataAddressType const& _aTreeRef, Accessor const& _rReaderAccess)
{ return static_cast<DataPointerType>(_rReaderAccess.access(_aTreeRef.m_pData)); }
private:
NodeAddress rootAddress(DataAddressType const& p) const;
TreeAccessor();
private: private:
Accessor m_aAccessor; TreeAddress m_pTree;
DataAddressType m_pBase;
}; };
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
// -------------------------------------------------------------------------
inline
TreeAccessor::Name TreeAccessor::getName() const
{
return wrapName( data().getName() );
}
// -------------------------------------------------------------------------
inline
NodeAddress TreeAccessor::rootAddress(DataAddressType const& p) const
{
sharable::Address aAddr = p.addressValue();
if (aAddr) aAddr += offsetof(TreeAddress::DataType,nodes);
return NodeAddress( memory::Pointer(aAddr) );
}
// -------------------------------------------------------------------------
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
} // namespace configmgr } // namespace configmgr
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment