1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #ifndef ADC_CPP_SUB_PEU_HXX
29 #define ADC_CPP_SUB_PEU_HXX
30 
31 
32 
33 // USED SERVICES
34 	// BASE CLASSES
35 #include <semantic/parseenv.hxx>
36 #include <tokens/tokproct.hxx>
37 	// COMPONENTS
38 	// PARAMETERS
39 #include <semantic/sub_pe.hxx>
40 
41 
42 
43 template <class PE, class SUB>
44 class SubPeUse  : public SubPeUseIfc,
45 				  private TokenProcessing_Types
46 {
47   public:
48 	typedef void (PE::*F_INIT)();
49 	typedef void (PE::*F_RETURN)();
50 
51 						SubPeUse(
52 							SubPe<PE,SUB> &		i_rSubPeCreator,
53 							F_INIT				i_fInit,
54 							F_RETURN 			i_fReturn );
55 						~SubPeUse();
56 
57 	void				Push(
58 							E_TokenDone			i_eDone	);
59 	virtual void		InitParse() const;
60 	virtual void		GetResults() const;
61 
62     PE &                Parent() const;
63     SUB &               Child() const;
64 
65   private:
66 	// DATA
67 	SubPe<PE,SUB> &		rSubPeCreator;
68 	F_INIT              fInit;
69 	F_RETURN 			fReturn;
70 };
71 
72 
73 // IMPLEMENTATION
74 
75 
76 template <class PE, class SUB>
77 SubPeUse<PE,SUB>::SubPeUse( SubPe<PE,SUB> &		i_rSubPeCreator,
78 						F_INIT				i_fInit,
79 						F_RETURN 			i_fReturn )
80 	:	rSubPeCreator(i_rSubPeCreator),
81 		fInit(i_fInit),
82 		fReturn(i_fReturn)
83 {
84 }
85 
86 template <class PE, class SUB>
87 SubPeUse<PE,SUB>::~SubPeUse()
88 {
89 }
90 
91 template <class PE, class SUB>
92 void
93 SubPeUse<PE,SUB>::Push( E_TokenDone i_eDone )
94 {
95 	Parent().SetTokenResult( i_eDone, push, &rSubPeCreator.Get() );
96 	Parent().SetCurSPU(this);
97 }
98 
99 template <class PE, class SUB>
100 void
101 SubPeUse<PE,SUB>::InitParse() const
102 {
103 	if (fInit != 0)
104 		(Parent().*fInit)();
105 }
106 
107 template <class PE, class SUB>
108 void
109 SubPeUse<PE,SUB>::GetResults() const
110 {
111 	if (fReturn != 0)
112 		(Parent().*fReturn)();
113 }
114 
115 template <class PE, class SUB>
116 inline PE &
117 SubPeUse<PE,SUB>::Parent() const
118 {
119  	return rSubPeCreator.Parent();
120 }
121 
122 template <class PE, class SUB>
123 inline SUB &
124 SubPeUse<PE,SUB>::Child() const
125 {
126  	return rSubPeCreator.Child();
127 }
128 
129 
130 #endif
131 
132