/************************************************************************* * * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: setnodeaccess.hxx,v $ * * $Revision: 1.6 $ * * last change: $Author: ihi $ $Date: 2007-11-23 14:24:44 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. * * * GNU Lesser General Public License Version 2.1 * ============================================= * Copyright 2005 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 * ************************************************************************/ #ifndef CONFIGMGR_SETNODEACCESS_HXX #define CONFIGMGR_SETNODEACCESS_HXX #ifndef CONFIGMGR_NODEACCESS_HXX #include "nodeaccess.hxx" #endif #ifndef INCLUDED_SHARABLE_TREEFRAGMENT_HXX #include "treefragment.hxx" #endif #include "treeaccessor.hxx" namespace configmgr { // ----------------------------------------------------------------------------- namespace data { // ------------------------------------------------------------------------- class TreeAccessor; // ------------------------------------------------------------------------- /** class that mediates access to the data of a Set node
Is a handle class with reference copy semantics.
*/ class SetNodeAccess { public: typedef TreeAddress ElementAddress; typedef TreeAccessor ElementAccess; SetNodeAccess(const sharable::SetNode *_pNodeRef) : m_pData((SetNodeAddress)_pNodeRef) {} SetNodeAccess(const sharable::Node *_pNodeRef) : m_pData(check(_pNodeRef)) {} explicit SetNodeAccess(NodeAccess const & _aNode) : m_pData(check(_aNode)) {} static bool isInstance(NodeAccess const & _aNode) { return check(_aNode) != NULL; } bool isValid() const { return m_pData != NULL; } configuration::Name getName() const; node::Attributes getAttributes() const; bool isDefault() const; bool isLocalizedValueSetNode() const; configuration::Name getElementTemplateName() const; configuration::Name getElementTemplateModule() const; bool hasElement (configuration::Name const& _aName) const { return SetNodeAccess::implGetElement(_aName) != NULL; } ElementAccess getElementTree (configuration::Name const& _aName) const { return TreeAccessor(implGetElement(_aName)); } operator NodeAccess() const { return NodeAccess(NodeAddress(m_pData)); } sharable::SetNode & data() const { return *m_pData; } operator SetNodeAddress () const { return (SetNodeAddress)m_pData; } operator NodeAddress () const { return (NodeAddress)m_pData; } static void addElement(SetNodeAddress _aSetAddress, ElementAddress _aNewElement); static ElementAddress removeElement(SetNodeAddress _aSetAddress, configuration::Name const & _aName); private: static SetNodeAddress check(sharable::Node *pNode) { return pNode ? const_cast