update dev300-m58
[ooovba.git] / configmgr / source / api2 / apitreeaccess.hxx
bloba0d8659c02dd866aba284d1f7dbea7218e450bac
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: apitreeaccess.hxx,v $
10 * $Revision: 1.13 $
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; }
45 namespace configmgr
47 //-----------------------------------------------------------------------------
48 struct ServiceImplementationInfo;
49 //-----------------------------------------------------------------------------
50 namespace configuration
52 class ElementTree;
53 class Template;
54 class Tree;
56 //-----------------------------------------------------------------------------
57 namespace configapi
59 //-----------------------------------------------------------------------------
60 namespace uno = com::sun::star::uno;
61 //-----------------------------------------------------------------------------
62 class Factory;
63 class Notifier;
64 class Committer;
65 class NodeSetInfoAccess;
66 //-----------------------------------------------------------------------------
67 // API object implementation wrappers
68 //-------------------------------------------------------------------------
69 class ApiTreeImpl;
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
77 public:
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(); }
89 private:
90 virtual uno::XInterface* doGetUnoInstance() const = 0;
91 virtual ServiceImplementationInfo const* doGetServiceInfo() const = 0;
92 virtual ApiTreeImpl& getApiTree() const = 0;
94 friend class Factory;
96 //-----------------------------------------------------------------------------
98 // A class for tagging inner nodes
99 class InnerElement : public NodeElement
101 public:
102 // Only used as a tag
104 //-----------------------------------------------------------------------------
106 // A common base class for tree-owning elemnt classes
107 class TreeElement : public NodeElement
109 public:
110 // model access
111 rtl::Reference< configuration::Tree > getTreeRef() const;
112 rtl::Reference< configuration::Tree > getTree() const;
114 // api object handling
115 Factory& getFactory();
117 protected:
118 virtual ApiTreeImpl& getApiTree() const = 0;
120 //-----------------------------------------------------------------------------
122 // Info interfaces for Set Elements
123 class SetElement : public TreeElement
125 public:
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
139 public:
140 bool disposeTree();
141 protected:
142 virtual ApiRootTreeImpl& getRootTree() = 0;
144 //-----------------------------------------------------------------------------
146 // Info interfaces for Set Elements
147 class UpdateRootElement : public RootElement
149 public:
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 {
156 UnoApiLock m_aLock;
157 TreeElement & m_rTree;
159 public:
160 explicit GuardedTreeElement(TreeElement & rTree): m_rTree(rTree)
161 { rTree.checkAlive(); }
163 TreeElement & get() const { return m_rTree; }
166 class GuardedRootElement {
167 UnoApiLock m_aLock;
168 RootElement & m_rTree;
170 public:
171 explicit GuardedRootElement(RootElement & rTree): m_rTree(rTree)
172 { rTree.checkAlive(); }
174 RootElement & get() const { return m_rTree; }
179 #endif // CONFIGMGR_API_TREEACCESS_HXX_