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 ADC_CPP_SUB_PEU_HXX
25 #define ADC_CPP_SUB_PEU_HXX
26 
27 
28 
29 // USED SERVICES
30 	// BASE CLASSES
31 #include <semantic/parseenv.hxx>
32 #include <tokens/tokproct.hxx>
33 	// COMPONENTS
34 	// PARAMETERS
35 #include <semantic/sub_pe.hxx>
36 
37 
38 
39 template <class PE, class SUB>
40 class SubPeUse  : public SubPeUseIfc,
41 				  private TokenProcessing_Types
42 {
43   public:
44 	typedef void (PE::*F_INIT)();
45 	typedef void (PE::*F_RETURN)();
46 
47 						SubPeUse(
48 							SubPe<PE,SUB> &		i_rSubPeCreator,
49 							F_INIT				i_fInit,
50 							F_RETURN 			i_fReturn );
51 						~SubPeUse();
52 
53 	void				Push(
54 							E_TokenDone			i_eDone	);
55 	virtual void		InitParse() const;
56 	virtual void		GetResults() const;
57 
58     PE &                Parent() const;
59     SUB &               Child() const;
60 
61   private:
62 	// DATA
63 	SubPe<PE,SUB> &		rSubPeCreator;
64 	F_INIT              fInit;
65 	F_RETURN 			fReturn;
66 };
67 
68 
69 // IMPLEMENTATION
70 
71 
72 template <class PE, class SUB>
SubPeUse(SubPe<PE,SUB> & i_rSubPeCreator,F_INIT i_fInit,F_RETURN i_fReturn)73 SubPeUse<PE,SUB>::SubPeUse( SubPe<PE,SUB> &		i_rSubPeCreator,
74 						F_INIT				i_fInit,
75 						F_RETURN 			i_fReturn )
76 	:	rSubPeCreator(i_rSubPeCreator),
77 		fInit(i_fInit),
78 		fReturn(i_fReturn)
79 {
80 }
81 
82 template <class PE, class SUB>
~SubPeUse()83 SubPeUse<PE,SUB>::~SubPeUse()
84 {
85 }
86 
87 template <class PE, class SUB>
88 void
Push(E_TokenDone i_eDone)89 SubPeUse<PE,SUB>::Push( E_TokenDone i_eDone )
90 {
91 	Parent().SetTokenResult( i_eDone, push, &rSubPeCreator.Get() );
92 	Parent().SetCurSPU(this);
93 }
94 
95 template <class PE, class SUB>
96 void
InitParse() const97 SubPeUse<PE,SUB>::InitParse() const
98 {
99 	if (fInit != 0)
100 		(Parent().*fInit)();
101 }
102 
103 template <class PE, class SUB>
104 void
GetResults() const105 SubPeUse<PE,SUB>::GetResults() const
106 {
107 	if (fReturn != 0)
108 		(Parent().*fReturn)();
109 }
110 
111 template <class PE, class SUB>
112 inline PE &
Parent() const113 SubPeUse<PE,SUB>::Parent() const
114 {
115  	return rSubPeCreator.Parent();
116 }
117 
118 template <class PE, class SUB>
119 inline SUB &
Child() const120 SubPeUse<PE,SUB>::Child() const
121 {
122  	return rSubPeCreator.Child();
123 }
124 
125 
126 #endif
127 
128