xref: /aoo4110/main/cppu/inc/cppu/Enterable.hxx (revision b1cdbd2c)
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_cppu_Enterable_hxx
25 #define INCLUDED_cppu_Enterable_hxx
26 
27 #include "uno/Enterable.h"
28 #include "rtl/ustring.hxx"
29 
30 namespace cppu
31 {
32 /** C++ wrapper for binary C Enterable
33     (http://wiki.services.openoffice.org/wiki/Uno/Cpp/Spec/Environment_Stack)
34 
35     @see uno_Enterable
36     @since UDK 3.2.7
37 */
38 class Enterable : public uno_Enterable
39 {
40 public:
41     /* These methods need to be implemented in a derived class.
42      */
43 	virtual void v_enter     (void)                                      = 0;
44 	virtual void v_leave     (void)                                      = 0;
45 	virtual void v_callInto_v(uno_EnvCallee * pCallee, va_list * pParam) = 0;
46 	virtual void v_callOut_v (uno_EnvCallee * pCallee, va_list * pParam) = 0;
47 	virtual int  v_isValid   (rtl::OUString * pReason)                   = 0;
48 
~Enterable()49     virtual ~Enterable() {}
50 
51 public:
52 	inline explicit Enterable(void);
53 
enter(void)54 	inline void enter(void) {m_enter(this);}
leave(void)55 	inline void leave(void) {m_leave(this);}
56 
callInto_v(uno_EnvCallee * pCallee,va_list * pParam)57 	inline void callInto_v(uno_EnvCallee * pCallee, va_list * pParam) {m_callInto_v(this, pCallee, pParam);}
callOut_v(uno_EnvCallee * pCallee,va_list * pParam)58 	inline void callOut_v (uno_EnvCallee * pCallee, va_list * pParam) {m_callOut_v (this, pCallee, pParam);}
59 
60 	inline void callInto(uno_EnvCallee * pCallee, ...);
61 	inline void callOut (uno_EnvCallee * pCallee, ...);
62 
isValid(rtl::OUString * pReason)63 	inline int  isValid (rtl::OUString * pReason) {return m_isValid(this, (rtl_uString **)pReason);}
64 
65 private:
66 	Enterable(Enterable const &);
67 	Enterable & operator = (Enterable const &);
68 };
69 
Enterable_call_enter(void * context)70 extern "C" inline void Enterable_call_enter (void * context) { ((Enterable *)context)->v_enter(); }
Enterable_call_leave(void * context)71 extern "C" inline void Enterable_call_leave (void * context) { ((Enterable *)context)->v_leave(); }
Enterable_call_callInto_v(void * context,uno_EnvCallee * pCallee,va_list * pParam)72 extern "C" inline void Enterable_call_callInto_v(void * context, uno_EnvCallee * pCallee, va_list * pParam)
73     { ((Enterable *)context)->v_callInto_v(pCallee, pParam); }
Enterable_call_callOut_v(void * context,uno_EnvCallee * pCallee,va_list * pParam)74 extern "C" inline void Enterable_call_callOut_v (void * context, uno_EnvCallee * pCallee, va_list * pParam)
75     { ((Enterable *)context)->v_callOut_v(pCallee, pParam); }
Enterable_call_isValid(void * context,rtl_uString ** pReason)76 extern "C" inline int  Enterable_call_isValid   (void * context, rtl_uString ** pReason)
77     {return ((Enterable *)context)->v_isValid((rtl::OUString *)pReason);}
78 
79 
Enterable(void)80 Enterable::Enterable(void)
81 {
82     m_enter      = Enterable_call_enter;
83     m_leave      = Enterable_call_leave;
84     m_callInto_v = Enterable_call_callInto_v;
85     m_callOut_v  = Enterable_call_callOut_v;
86     m_isValid    = Enterable_call_isValid;
87 }
88 
callInto(uno_EnvCallee * pCallee,...)89 void Enterable::callInto(uno_EnvCallee * pCallee, ...)
90 {
91 	va_list param;
92 
93 	va_start(param, pCallee);
94 	callInto_v(pCallee, &param);
95 	va_end(param);
96 }
97 
callOut(uno_EnvCallee * pCallee,...)98 void Enterable::callOut(uno_EnvCallee * pCallee, ...)
99 {
100 	va_list param;
101 
102 	va_start(param, pCallee);
103 	callOut_v(pCallee, &param);
104 	va_end(param);
105 }
106 
107 }
108 
109 
110 #endif
111