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: apifactory.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_FACTORY_HXX_
32 #define CONFIGMGR_API_FACTORY_HXX_
34 #include "options.hxx"
35 #include "utility.hxx"
36 #include <boost/utility.hpp>
37 #include <rtl/ref.hxx>
38 #include <vos/ref.hxx>
39 #include <cppuhelper/typeprovider.hxx>
43 namespace configuration
53 namespace uno
= com::sun::star::uno
;
62 // used to register objects
65 // used to create UNO objects
66 class Factory
: private boost::noncopyable
68 rtl::Reference
<ObjectRegistry
> m_pRegistry
;
69 cppu::OImplementationId
const m_aTunnelID
;
72 /// return the element _without_ acquiring it
73 NodeElement
* implFind(configuration::NodeID
const& aNode
);
76 Factory(rtl::Reference
<ObjectRegistry
> pRegistry
);
79 uno::Reference
< uno::XInterface
> makeUnoElement(rtl::Reference
< configuration::Tree
> const& aTree
, configuration::NodeRef
const& aNode
);
80 uno::Reference
< uno::XInterface
> findUnoElement(configuration::NodeID
const& aNode
);
82 uno::Reference
< uno::XInterface
> makeUnoSetElement(rtl::Reference
< configuration::ElementTree
> const& aTree
);
84 NodeElement
* makeElement(rtl::Reference
< configuration::Tree
> const& aTree
, configuration::NodeRef
const& aNode
);
85 NodeElement
* findElement(configuration::NodeID
const& aNode
);
87 TreeElement
* makeAccessRoot(rtl::Reference
< configuration::Tree
> const& aTree
, RequestOptions
const& _aOptions
);
88 SetElement
* makeSetElement(rtl::Reference
< configuration::ElementTree
> const& aTree
);
90 SetElement
* findSetElement(rtl::Reference
< configuration::ElementTree
> const& aElement
);
92 /// check for the existence of an element
93 sal_Bool
hasElement(configuration::NodeID
const& _rNode
) { return NULL
!= implFind(_rNode
); }
95 void revokeElement(configuration::NodeID
const& aNode
);
97 SetElement
* extractSetElement(uno::Any
const& aElement
);
98 bool tunnelSetElement(sal_Int64
& nSomething
, SetElement
& rElement
, uno::Sequence
< sal_Int8
> const& aTunnelID
);
99 // registry operations
101 static ApiTreeImpl
const* findDescendantTreeImpl(configuration::NodeID
const& aNode
, ApiTreeImpl
const* pImpl
);
103 void doRegisterElement(configuration::NodeID
const& aNode
, NodeElement
* pElement
);
104 void doRevokeElement(configuration::NodeID
const& aNode
, NodeElement
* pElement
);
106 uno::Sequence
< sal_Int8
> doGetElementTunnelID() const { return m_aTunnelID
.getImplementationId(); }
108 virtual NodeElement
* doCreateGroupMember(rtl::Reference
< configuration::Tree
> const& aTree
, configuration::NodeRef
const& aNode
, configuration::Template
* pSetElementTemplate
) = 0;
109 virtual TreeElement
* doCreateAccessRoot(rtl::Reference
< configuration::Tree
> const& aTree
, configuration::Template
* pSetElementTemplate
, vos::ORef
< OOptions
>const& _xOptions
) = 0;
110 virtual SetElement
* doCreateSetElement(rtl::Reference
< configuration::ElementTree
> const& aTree
, configuration::Template
* pSetElementTemplate
) = 0;
112 static ApiTreeImpl
& getImplementation(NodeElement
& pElement
);
114 static rtl::Reference
<configuration::Template
> implGetSetElementTemplate(rtl::Reference
< configuration::Tree
> const& aTree
, configuration::NodeRef
const& aNode
);
115 static uno::Reference
< uno::XInterface
> implToUno(NodeElement
* pNode
);
116 void implHaveNewElement(configuration::NodeID aNodeID
, NodeElement
* pNode
);
122 #endif // CONFIGMGR_API_FACTORY_HXX_