1*3638366cSAndrew Rist /**************************************************************
2*3638366cSAndrew Rist  *
3*3638366cSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*3638366cSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*3638366cSAndrew Rist  * distributed with this work for additional information
6*3638366cSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*3638366cSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*3638366cSAndrew Rist  * "License"); you may not use this file except in compliance
9*3638366cSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*3638366cSAndrew Rist  *
11*3638366cSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*3638366cSAndrew Rist  *
13*3638366cSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*3638366cSAndrew Rist  * software distributed under the License is distributed on an
15*3638366cSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*3638366cSAndrew Rist  * KIND, either express or implied.  See the License for the
17*3638366cSAndrew Rist  * specific language governing permissions and limitations
18*3638366cSAndrew Rist  * under the License.
19*3638366cSAndrew Rist  *
20*3638366cSAndrew Rist  *************************************************************/
21*3638366cSAndrew Rist 
22*3638366cSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef INCLUDED_BINARYURP_SOURCE_BRIDGEFACTORY_HXX
25cdf0e10cSrcweir #define INCLUDED_BINARYURP_SOURCE_BRIDGEFACTORY_HXX
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include "sal/config.h"
28cdf0e10cSrcweir 
29cdf0e10cSrcweir #include <list>
30cdf0e10cSrcweir #include <map>
31cdf0e10cSrcweir 
32cdf0e10cSrcweir #include "boost/noncopyable.hpp"
33cdf0e10cSrcweir #include "com/sun/star/bridge/XBridgeFactory.hpp"
34cdf0e10cSrcweir #include "com/sun/star/lang/XServiceInfo.hpp"
35cdf0e10cSrcweir #include "com/sun/star/uno/Exception.hpp"
36cdf0e10cSrcweir #include "com/sun/star/uno/Reference.hxx"
37cdf0e10cSrcweir #include "com/sun/star/uno/RuntimeException.hpp"
38cdf0e10cSrcweir #include "cppuhelper/compbase2.hxx"
39cdf0e10cSrcweir #include "sal/types.h"
40cdf0e10cSrcweir 
41cdf0e10cSrcweir namespace com { namespace sun { namespace star {
42cdf0e10cSrcweir     namespace connection { class XConnection; }
43cdf0e10cSrcweir     namespace uno {
44cdf0e10cSrcweir         class XComponentContext;
45cdf0e10cSrcweir         class XInterface;
46cdf0e10cSrcweir     }
47cdf0e10cSrcweir } } }
48cdf0e10cSrcweir 
49cdf0e10cSrcweir namespace binaryurp {
50cdf0e10cSrcweir 
51cdf0e10cSrcweir // That BridgeFactory derives from XComponent appears to be a historic mistake;
52cdf0e10cSrcweir // the implementation does not care about a disposed state:
53cdf0e10cSrcweir 
54cdf0e10cSrcweir typedef
55cdf0e10cSrcweir     cppu::WeakComponentImplHelper2<
56cdf0e10cSrcweir         com::sun::star::lang::XServiceInfo,
57cdf0e10cSrcweir         com::sun::star::bridge::XBridgeFactory >
58cdf0e10cSrcweir     BridgeFactoryBase;
59cdf0e10cSrcweir 
60cdf0e10cSrcweir class BridgeFactory:
61cdf0e10cSrcweir     private osl::Mutex, public BridgeFactoryBase, private boost::noncopyable
62cdf0e10cSrcweir {
63cdf0e10cSrcweir public:
64cdf0e10cSrcweir     static com::sun::star::uno::Reference< com::sun::star::uno::XInterface >
65cdf0e10cSrcweir     SAL_CALL static_create(
66cdf0e10cSrcweir         com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext >
67cdf0e10cSrcweir             const & xContext)
68cdf0e10cSrcweir         SAL_THROW((com::sun::star::uno::Exception));
69cdf0e10cSrcweir 
70cdf0e10cSrcweir     static rtl::OUString SAL_CALL static_getImplementationName();
71cdf0e10cSrcweir 
72cdf0e10cSrcweir     static com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL
73cdf0e10cSrcweir     static_getSupportedServiceNames();
74cdf0e10cSrcweir 
75cdf0e10cSrcweir     void removeBridge(
76cdf0e10cSrcweir         com::sun::star::uno::Reference< com::sun::star::bridge::XBridge >
77cdf0e10cSrcweir             const & bridge);
78cdf0e10cSrcweir 
79cdf0e10cSrcweir     using BridgeFactoryBase::acquire;
80cdf0e10cSrcweir     using BridgeFactoryBase::release;
81cdf0e10cSrcweir 
82cdf0e10cSrcweir private:
83cdf0e10cSrcweir     explicit BridgeFactory(
84cdf0e10cSrcweir         com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext >
85cdf0e10cSrcweir             const & context);
86cdf0e10cSrcweir 
87cdf0e10cSrcweir     virtual ~BridgeFactory();
88cdf0e10cSrcweir 
89cdf0e10cSrcweir     virtual rtl::OUString SAL_CALL getImplementationName()
90cdf0e10cSrcweir         throw (com::sun::star::uno::RuntimeException);
91cdf0e10cSrcweir 
92cdf0e10cSrcweir     virtual sal_Bool SAL_CALL supportsService(rtl::OUString const & ServiceName)
93cdf0e10cSrcweir         throw (com::sun::star::uno::RuntimeException);
94cdf0e10cSrcweir 
95cdf0e10cSrcweir     virtual com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL
96cdf0e10cSrcweir     getSupportedServiceNames() throw (com::sun::star::uno::RuntimeException);
97cdf0e10cSrcweir 
98cdf0e10cSrcweir     virtual com::sun::star::uno::Reference< com::sun::star::bridge::XBridge >
99cdf0e10cSrcweir     SAL_CALL createBridge(
100cdf0e10cSrcweir         rtl::OUString const & sName, rtl::OUString const & sProtocol,
101cdf0e10cSrcweir         com::sun::star::uno::Reference<
102cdf0e10cSrcweir             com::sun::star::connection::XConnection > const & aConnection,
103cdf0e10cSrcweir         com::sun::star::uno::Reference<
104cdf0e10cSrcweir             com::sun::star::bridge::XInstanceProvider > const &
105cdf0e10cSrcweir                 anInstanceProvider)
106cdf0e10cSrcweir         throw (
107cdf0e10cSrcweir             com::sun::star::bridge::BridgeExistsException,
108cdf0e10cSrcweir             com::sun::star::lang::IllegalArgumentException,
109cdf0e10cSrcweir             com::sun::star::uno::RuntimeException);
110cdf0e10cSrcweir 
111cdf0e10cSrcweir     virtual com::sun::star::uno::Reference< com::sun::star::bridge::XBridge >
112cdf0e10cSrcweir     SAL_CALL getBridge(
113cdf0e10cSrcweir         rtl::OUString const & sName)
114cdf0e10cSrcweir         throw (com::sun::star::uno::RuntimeException);
115cdf0e10cSrcweir 
116cdf0e10cSrcweir     virtual
117cdf0e10cSrcweir     com::sun::star::uno::Sequence<
118cdf0e10cSrcweir         com::sun::star::uno::Reference< com::sun::star::bridge::XBridge > >
119cdf0e10cSrcweir     SAL_CALL getExistingBridges() throw (com::sun::star::uno::RuntimeException);
120cdf0e10cSrcweir 
121cdf0e10cSrcweir     typedef
122cdf0e10cSrcweir         std::list<
123cdf0e10cSrcweir             com::sun::star::uno::Reference< com::sun::star::bridge::XBridge > >
124cdf0e10cSrcweir         BridgeList;
125cdf0e10cSrcweir 
126cdf0e10cSrcweir     typedef
127cdf0e10cSrcweir         std::map<
128cdf0e10cSrcweir             rtl::OUString,
129cdf0e10cSrcweir             com::sun::star::uno::Reference< com::sun::star::bridge::XBridge > >
130cdf0e10cSrcweir         BridgeMap;
131cdf0e10cSrcweir 
132cdf0e10cSrcweir     com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext >
133cdf0e10cSrcweir         context_;
134cdf0e10cSrcweir     BridgeList unnamed_;
135cdf0e10cSrcweir     BridgeMap named_;
136cdf0e10cSrcweir };
137cdf0e10cSrcweir 
138cdf0e10cSrcweir }
139cdf0e10cSrcweir 
140cdf0e10cSrcweir #endif
141