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: apitreeaccess.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_API_TREEACCESS_HXX_
32 #define CONFIGMGR_API_TREEACCESS_HXX_
34 #include "sal/config.h"
36 #include "boost/utility.hpp"
37 #include "rtl/ref.hxx"
39 #include "datalock.hxx"
40 #include "options.hxx"
41 #include "utility.hxx"
43 namespace osl
{ class Mutex
; }
47 //-----------------------------------------------------------------------------
48 struct ServiceImplementationInfo
;
49 //-----------------------------------------------------------------------------
50 namespace configuration
56 //-----------------------------------------------------------------------------
59 //-----------------------------------------------------------------------------
60 namespace uno
= com::sun::star::uno
;
61 //-----------------------------------------------------------------------------
65 class NodeSetInfoAccess
;
66 //-----------------------------------------------------------------------------
67 // API object implementation wrappers
68 //-------------------------------------------------------------------------
70 class ApiRootTreeImpl
;
72 // these objects just provide the pieces needed to navigate and manipulate trees and nodes
74 // A common base class for 'element' classes
75 class NodeElement
: private boost::noncopyable
78 virtual ~NodeElement() {}
80 // self-locked methods for dispose handling
81 void checkAlive() const;
83 // api object handling
84 uno::XInterface
* getUnoInstance() const
85 { return doGetUnoInstance(); }
87 ServiceImplementationInfo
const * getServiceInfo() const
88 { return doGetServiceInfo(); }
90 virtual uno::XInterface
* doGetUnoInstance() const = 0;
91 virtual ServiceImplementationInfo
const* doGetServiceInfo() const = 0;
92 virtual ApiTreeImpl
& getApiTree() const = 0;
96 //-----------------------------------------------------------------------------
98 // A class for tagging inner nodes
99 class InnerElement
: public NodeElement
102 // Only used as a tag
104 //-----------------------------------------------------------------------------
106 // A common base class for tree-owning elemnt classes
107 class TreeElement
: public NodeElement
111 rtl::Reference
< configuration::Tree
> getTreeRef() const;
112 rtl::Reference
< configuration::Tree
> getTree() const;
114 // api object handling
115 Factory
& getFactory();
118 virtual ApiTreeImpl
& getApiTree() const = 0;
120 //-----------------------------------------------------------------------------
122 // Info interfaces for Set Elements
123 class SetElement
: public TreeElement
126 // self-locked methods for dispose handling
127 bool disposeTree(bool bForceDispose
);
129 void haveNewParent(NodeSetInfoAccess
* pNewParent
);
131 rtl::Reference
< configuration::ElementTree
> getElementRef() const;
132 rtl::Reference
< configuration::Template
> getTemplateInfo() const;
134 //-----------------------------------------------------------------------------
136 // Info interfaces for Set Elements
137 class RootElement
: public TreeElement
142 virtual ApiRootTreeImpl
& getRootTree() = 0;
144 //-----------------------------------------------------------------------------
146 // Info interfaces for Set Elements
147 class UpdateRootElement
: public RootElement
150 Committer
getCommitter();
153 // Thin Wrappers around TreeElements: Provide guarding and convenient access
154 /// wraps a TreeElement; provides an object (read) lock, ensures object was not disposed
155 class GuardedTreeElement
{
157 TreeElement
& m_rTree
;
160 explicit GuardedTreeElement(TreeElement
& rTree
): m_rTree(rTree
)
161 { rTree
.checkAlive(); }
163 TreeElement
& get() const { return m_rTree
; }
166 class GuardedRootElement
{
168 RootElement
& m_rTree
;
171 explicit GuardedRootElement(RootElement
& rTree
): m_rTree(rTree
)
172 { rTree
.checkAlive(); }
174 RootElement
& get() const { return m_rTree
; }
179 #endif // CONFIGMGR_API_TREEACCESS_HXX_