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