Update ooo320-m1
[ooovba.git] / autodoc / source / parser_i / inc / s2_luidl / distrib.hxx
blobed05ddb77502ba3609bef43c118af7e53312ce96
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: distrib.hxx,v $
10 * $Revision: 1.8 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef LUIDL_DISTRIB_HXX
32 #define LUIDL_DISTRIB_HXX
36 // USED SERVICES
37 // BASE CLASSES
38 #include <s2_luidl/tokrecv.hxx>
39 #include <s2_dsapi/tokrecv.hxx>
40 #include <s2_luidl/tokproct.hxx>
41 // COMPONENTS
42 // PARAMETERS
45 class ParserInfo;
47 namespace ary
49 class Repository;
51 namespace doc
53 class OldIdlDocu;
54 } // namespace inf
55 } // namespace ary)
59 namespace csi
61 namespace dsapi
63 class Token_Receiver;
64 class SapiDocu_PE;
69 namespace uidl
73 typedef std::vector< DYN Token * > TokenQueue;
74 typedef TokenQueue::iterator TokenIterator;
76 class TokenParser_Uidl;
77 class UnoIDL_PE;
78 class Token;
81 class TokenDistributor : private TokenProcessing_Types
84 public:
85 TokenDistributor(
86 ary::Repository & io_rRepository,
87 ParserInfo & io_rParserInfo );
88 void SetTokenProvider(
89 TokenParser_Uidl & io_rTokenSource );
90 void SetTopParseEnvironment(
91 UnoIDL_PE & io_pTopParseEnvironment );
92 ~TokenDistributor();
95 void Reset() { aDocumentation.Reset(); }
96 /** calls pTokenSource->GetNextToken() and checks the incoming tokens, until a
97 usable token is found. This token will be forwarded to
98 pTopParseEnv;
100 void TradeToken();
102 csi::uidl::Token_Receiver &
103 CodeTokens_Receiver();
104 csi::dsapi::Token_Receiver &
105 DocuTokens_Receiver();
107 /** Used from PE_File, if there is a docu to get without
108 an environment to push (this is the case for modules).
110 DYN ary::doc::OldIdlDocu *
111 ReleaseLastParsedDocu()
112 { return aDocumentation.ReleaseLastParsedDocu(); }
114 /** Used from PE_File, if the term "published" was parsed.
115 The next opened parse environment will be set to be published
116 (call ->UnoIDL_PE::SetPublished()).
118 void Set_PublishedOn()
119 { aProcessingData.Set_PublishedOn(); }
122 private:
123 class Documentation;
124 class ProcessingData;
125 friend class ProcessingData;
127 class ProcessingData : public csi::uidl::Token_Receiver,
128 private TokenProcessing_Types
130 public:
131 ProcessingData(
132 ary::Repository & io_rRepository,
133 Documentation & i_rDocuProcessor,
134 ParserInfo & io_rParserInfo );
135 ~ProcessingData();
136 void SetTopParseEnvironment(
137 UnoIDL_PE & io_pTopParseEnvironment );
140 /** is called from pTokenSource before finishing a ::TokenParse2::GetNextToken()
141 call and passes the just parsed token to this class.
143 virtual void Receive(
144 DYN csi::uidl::Token &
145 let_drToken );
146 virtual void Increment_CurLine();
148 void ProcessCurToken();
150 UnoIDL_PE & CurEnvironment() const;
151 bool NextTokenExists() const;
152 void Set_PublishedOn()
153 { bPublishedRecentlyOn = true; }
155 private:
156 typedef uintt TokenQ_Position;
157 typedef std::pair< UnoIDL_PE *, TokenQ_Position > EnvironmentInfo;
158 typedef std::vector< EnvironmentInfo > EnvironmentStack;
160 void AcknowledgeResult();
161 const csi::uidl::Token &
162 CurToken() const;
163 UnoIDL_PE & CurEnv() const;
164 UnoIDL_PE & PushEnv() const;
165 uintt CurTokenPosition() const;
166 uintt CurEnv_TriedTokenPosition() const;
167 void DecrementTryCount();
169 EnvironmentStack aEnvironments;
170 TokenQueue aTokenQueue;
171 TokenIterator itCurToken;
172 TokenProcessing_Result
173 aCurResult;
174 uintt nTryCount;
175 bool bFinished;
176 ary::Repository &
177 rRepository;
178 ParserInfo & rParserInfo;
179 Documentation * pDocuProcessor;
180 bool bPublishedRecentlyOn;
183 class Documentation : public csi::dsapi::Token_Receiver
185 public:
186 Documentation(
187 ParserInfo & io_rParserInfo);
188 ~Documentation();
190 void Reset() { bIsPassedFirstDocu = false; }
192 virtual void Receive(
193 DYN csi::dsapi::Token &
194 let_drToken );
195 virtual void Increment_CurLine();
196 DYN ary::doc::OldIdlDocu *
197 ReleaseLastParsedDocu()
198 { return pMostRecentDocu.Release(); }
199 private:
200 Dyn<csi::dsapi::SapiDocu_PE>
201 pDocuParseEnv;
202 ParserInfo & rParserInfo;
203 Dyn<ary::doc::OldIdlDocu>
204 pMostRecentDocu;
205 bool bIsPassedFirstDocu;
208 // DATA
209 TokenParser_Uidl * pTokenSource;
210 Documentation aDocumentation;
211 ProcessingData aProcessingData;
216 // IMPLEMENTATION
218 inline void
219 TokenDistributor::SetTokenProvider( TokenParser_Uidl & io_rTokenSource )
220 { pTokenSource = &io_rTokenSource; }
222 inline void
223 TokenDistributor::SetTopParseEnvironment( UnoIDL_PE & io_pTopParseEnvironment )
224 { aProcessingData.SetTopParseEnvironment(io_pTopParseEnvironment); }
226 inline csi::uidl::Token_Receiver &
227 TokenDistributor::CodeTokens_Receiver()
228 { return aProcessingData; }
230 inline csi::dsapi::Token_Receiver &
231 TokenDistributor::DocuTokens_Receiver()
232 { return aDocumentation; }
234 inline const csi::uidl::Token &
235 TokenDistributor::ProcessingData::CurToken() const
237 csv_assert( itCurToken != aTokenQueue.end() );
238 csv_assert( *itCurToken != 0 );
239 return *(*itCurToken);
242 inline UnoIDL_PE &
243 TokenDistributor::ProcessingData::CurEnv() const
245 csv_assert( aEnvironments.size() > 0 );
246 csv_assert( aEnvironments.back().first != 0 );
247 return *aEnvironments.back().first;
250 inline UnoIDL_PE &
251 TokenDistributor::ProcessingData::PushEnv() const
253 csv_assert( aCurResult.pEnv2Push != 0 );
254 return *aCurResult.pEnv2Push;
257 inline uintt
258 TokenDistributor::ProcessingData::CurTokenPosition() const
260 return itCurToken - aTokenQueue.begin();
263 inline uintt
264 TokenDistributor::ProcessingData::CurEnv_TriedTokenPosition() const
266 csv_assert( aEnvironments.size() > 0 );
267 return aEnvironments.back().second;
271 } // namespace uidl
272 } // namespace csi
274 #endif