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