1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir *
3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir *
5*cdf0e10cSrcweir * Copyright 2000, 2011 Oracle and/or its affiliates.
6*cdf0e10cSrcweir *
7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir *
9*cdf0e10cSrcweir * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir *
11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir *
15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir *
21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir *
26*cdf0e10cSrcweir ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir #ifndef INCLUDED_BINARYURP_SOURCE_BRIDGEFACTORY_HXX
29*cdf0e10cSrcweir #define INCLUDED_BINARYURP_SOURCE_BRIDGEFACTORY_HXX
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir #include "sal/config.h"
32*cdf0e10cSrcweir 
33*cdf0e10cSrcweir #include <list>
34*cdf0e10cSrcweir #include <map>
35*cdf0e10cSrcweir 
36*cdf0e10cSrcweir #include "boost/noncopyable.hpp"
37*cdf0e10cSrcweir #include "com/sun/star/bridge/XBridgeFactory.hpp"
38*cdf0e10cSrcweir #include "com/sun/star/lang/XServiceInfo.hpp"
39*cdf0e10cSrcweir #include "com/sun/star/uno/Exception.hpp"
40*cdf0e10cSrcweir #include "com/sun/star/uno/Reference.hxx"
41*cdf0e10cSrcweir #include "com/sun/star/uno/RuntimeException.hpp"
42*cdf0e10cSrcweir #include "cppuhelper/compbase2.hxx"
43*cdf0e10cSrcweir #include "sal/types.h"
44*cdf0e10cSrcweir 
45*cdf0e10cSrcweir namespace com { namespace sun { namespace star {
46*cdf0e10cSrcweir     namespace connection { class XConnection; }
47*cdf0e10cSrcweir     namespace uno {
48*cdf0e10cSrcweir         class XComponentContext;
49*cdf0e10cSrcweir         class XInterface;
50*cdf0e10cSrcweir     }
51*cdf0e10cSrcweir } } }
52*cdf0e10cSrcweir 
53*cdf0e10cSrcweir namespace binaryurp {
54*cdf0e10cSrcweir 
55*cdf0e10cSrcweir // That BridgeFactory derives from XComponent appears to be a historic mistake;
56*cdf0e10cSrcweir // the implementation does not care about a disposed state:
57*cdf0e10cSrcweir 
58*cdf0e10cSrcweir typedef
59*cdf0e10cSrcweir     cppu::WeakComponentImplHelper2<
60*cdf0e10cSrcweir         com::sun::star::lang::XServiceInfo,
61*cdf0e10cSrcweir         com::sun::star::bridge::XBridgeFactory >
62*cdf0e10cSrcweir     BridgeFactoryBase;
63*cdf0e10cSrcweir 
64*cdf0e10cSrcweir class BridgeFactory:
65*cdf0e10cSrcweir     private osl::Mutex, public BridgeFactoryBase, private boost::noncopyable
66*cdf0e10cSrcweir {
67*cdf0e10cSrcweir public:
68*cdf0e10cSrcweir     static com::sun::star::uno::Reference< com::sun::star::uno::XInterface >
69*cdf0e10cSrcweir     SAL_CALL static_create(
70*cdf0e10cSrcweir         com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext >
71*cdf0e10cSrcweir             const & xContext)
72*cdf0e10cSrcweir         SAL_THROW((com::sun::star::uno::Exception));
73*cdf0e10cSrcweir 
74*cdf0e10cSrcweir     static rtl::OUString SAL_CALL static_getImplementationName();
75*cdf0e10cSrcweir 
76*cdf0e10cSrcweir     static com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL
77*cdf0e10cSrcweir     static_getSupportedServiceNames();
78*cdf0e10cSrcweir 
79*cdf0e10cSrcweir     void removeBridge(
80*cdf0e10cSrcweir         com::sun::star::uno::Reference< com::sun::star::bridge::XBridge >
81*cdf0e10cSrcweir             const & bridge);
82*cdf0e10cSrcweir 
83*cdf0e10cSrcweir     using BridgeFactoryBase::acquire;
84*cdf0e10cSrcweir     using BridgeFactoryBase::release;
85*cdf0e10cSrcweir 
86*cdf0e10cSrcweir private:
87*cdf0e10cSrcweir     explicit BridgeFactory(
88*cdf0e10cSrcweir         com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext >
89*cdf0e10cSrcweir             const & context);
90*cdf0e10cSrcweir 
91*cdf0e10cSrcweir     virtual ~BridgeFactory();
92*cdf0e10cSrcweir 
93*cdf0e10cSrcweir     virtual rtl::OUString SAL_CALL getImplementationName()
94*cdf0e10cSrcweir         throw (com::sun::star::uno::RuntimeException);
95*cdf0e10cSrcweir 
96*cdf0e10cSrcweir     virtual sal_Bool SAL_CALL supportsService(rtl::OUString const & ServiceName)
97*cdf0e10cSrcweir         throw (com::sun::star::uno::RuntimeException);
98*cdf0e10cSrcweir 
99*cdf0e10cSrcweir     virtual com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL
100*cdf0e10cSrcweir     getSupportedServiceNames() throw (com::sun::star::uno::RuntimeException);
101*cdf0e10cSrcweir 
102*cdf0e10cSrcweir     virtual com::sun::star::uno::Reference< com::sun::star::bridge::XBridge >
103*cdf0e10cSrcweir     SAL_CALL createBridge(
104*cdf0e10cSrcweir         rtl::OUString const & sName, rtl::OUString const & sProtocol,
105*cdf0e10cSrcweir         com::sun::star::uno::Reference<
106*cdf0e10cSrcweir             com::sun::star::connection::XConnection > const & aConnection,
107*cdf0e10cSrcweir         com::sun::star::uno::Reference<
108*cdf0e10cSrcweir             com::sun::star::bridge::XInstanceProvider > const &
109*cdf0e10cSrcweir                 anInstanceProvider)
110*cdf0e10cSrcweir         throw (
111*cdf0e10cSrcweir             com::sun::star::bridge::BridgeExistsException,
112*cdf0e10cSrcweir             com::sun::star::lang::IllegalArgumentException,
113*cdf0e10cSrcweir             com::sun::star::uno::RuntimeException);
114*cdf0e10cSrcweir 
115*cdf0e10cSrcweir     virtual com::sun::star::uno::Reference< com::sun::star::bridge::XBridge >
116*cdf0e10cSrcweir     SAL_CALL getBridge(
117*cdf0e10cSrcweir         rtl::OUString const & sName)
118*cdf0e10cSrcweir         throw (com::sun::star::uno::RuntimeException);
119*cdf0e10cSrcweir 
120*cdf0e10cSrcweir     virtual
121*cdf0e10cSrcweir     com::sun::star::uno::Sequence<
122*cdf0e10cSrcweir         com::sun::star::uno::Reference< com::sun::star::bridge::XBridge > >
123*cdf0e10cSrcweir     SAL_CALL getExistingBridges() throw (com::sun::star::uno::RuntimeException);
124*cdf0e10cSrcweir 
125*cdf0e10cSrcweir     typedef
126*cdf0e10cSrcweir         std::list<
127*cdf0e10cSrcweir             com::sun::star::uno::Reference< com::sun::star::bridge::XBridge > >
128*cdf0e10cSrcweir         BridgeList;
129*cdf0e10cSrcweir 
130*cdf0e10cSrcweir     typedef
131*cdf0e10cSrcweir         std::map<
132*cdf0e10cSrcweir             rtl::OUString,
133*cdf0e10cSrcweir             com::sun::star::uno::Reference< com::sun::star::bridge::XBridge > >
134*cdf0e10cSrcweir         BridgeMap;
135*cdf0e10cSrcweir 
136*cdf0e10cSrcweir     com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext >
137*cdf0e10cSrcweir         context_;
138*cdf0e10cSrcweir     BridgeList unnamed_;
139*cdf0e10cSrcweir     BridgeMap named_;
140*cdf0e10cSrcweir };
141*cdf0e10cSrcweir 
142*cdf0e10cSrcweir }
143*cdf0e10cSrcweir 
144*cdf0e10cSrcweir #endif
145