28 #include <comms-infras/corescpr.h> |
28 #include <comms-infras/corescpr.h> |
29 #include <comms-infras/corescprstates.h> |
29 #include <comms-infras/corescprstates.h> |
30 #include <comms-infras/ss_corepractivities.h> |
30 #include <comms-infras/ss_corepractivities.h> |
31 |
31 |
32 class CDummySubConnectionProviderFactory; |
32 class CDummySubConnectionProviderFactory; |
|
33 class CDummyVanillaSubConnectionProviderFactory; |
33 |
34 |
34 //-================================================ |
35 //-================================================ |
35 // |
36 // |
36 // States and Transitions |
37 // States and Transitions |
37 // |
38 // |
47 class TStoreFlowParams; |
48 class TStoreFlowParams; |
48 class TRequestCommsBinder; |
49 class TRequestCommsBinder; |
49 } |
50 } |
50 |
51 |
51 |
52 |
52 namespace ESock |
53 |
53 { |
54 /* We have to have CDummySubConnectionProvider inside the ESock namespace so it can befriend |
54 /* We have to have CDummySubConnectionProvider inside the ESock namespace so it can befriend |
55 mcfnode_cast - GCC simply doesn't allow befriending something in another template. See |
55 mcfnode_cast - GCC simply doesn't allow befriending something in another template. See |
56 http://gcc.gnu.org/ml/gcc-prs/2002-10/msg01010.html for Herb Sutter's GOTW column on exactly |
56 http://gcc.gnu.org/ml/gcc-prs/2002-10/msg01010.html for Herb Sutter's GOTW column on exactly |
57 this - it contains this discouraging summary: |
57 this - it contains this discouraging summary: |
58 |
58 |
59 The reason that I'm writing an article about it is because, alas, |
59 The reason that I'm writing an article about it is because, alas, |
60 befriending a template in another namespace is easier said than done: |
60 befriending a template in another namespace is easier said than done: |
61 |
61 |
62 - The Bad News: There are two perfectly good standards-conforming |
62 - The Bad News: There are two perfectly good standards-conforming |
63 ways to do it, and neither one works on all current compilers. |
63 ways to do it, and neither one works on all current compilers. |
64 |
64 |
65 - The Good News: One of the perfectly good standards-conforming ways |
65 - The Good News: One of the perfectly good standards-conforming ways |
66 does work on every current compiler I tried except for gcc. |
66 does work on every current compiler I tried except for gcc. |
67 |
67 |
68 So, since it's only test code & we need it building on GCC, I've hacked around it */ |
68 So, since it's only test code & we need it building on GCC, I've hacked around it */ |
|
69 |
|
70 class CDummySubConnectionProvider : public CCoreSubConnectionProvider |
69 class CDummySubConnectionProvider : public CCoreSubConnectionProvider |
71 /** |
70 /** |
72 |
71 |
73 @internalComponent |
72 @internalComponent |
74 @released since v9.4 |
73 @released since v9.4 |
83 friend NODE& mcfnode_cast(Messages::ANode& aNode); |
82 friend NODE& mcfnode_cast(Messages::ANode& aNode); |
84 #else |
83 #else |
85 friend CDummySubConnectionProvider* Messages::mnode_cast<CDummySubConnectionProvider>(ANode* aNode); |
84 friend CDummySubConnectionProvider* Messages::mnode_cast<CDummySubConnectionProvider>(ANode* aNode); |
86 friend CDummySubConnectionProvider& Messages::mnode_cast<CDummySubConnectionProvider>(ANode& aNode); |
85 friend CDummySubConnectionProvider& Messages::mnode_cast<CDummySubConnectionProvider>(ANode& aNode); |
87 #endif |
86 #endif |
88 friend class ::CDummySubConnectionProviderFactory; |
87 friend class CDummySubConnectionProviderFactory; |
|
88 friend class CDummyVanillaSubConnectionProviderFactory; |
89 friend class DummySCPRStates::TRaiseGranted; |
89 friend class DummySCPRStates::TRaiseGranted; |
90 |
90 |
91 public: |
91 public: |
92 virtual ~CDummySubConnectionProvider(); |
92 virtual ~CDummySubConnectionProvider(); |
93 void CDummySubConnectionProvider::SetToIncomingL(); |
93 void CDummySubConnectionProvider::SetToIncomingL(); |
94 |
94 |
95 protected: |
95 protected: |
96 static CDummySubConnectionProvider* NewL(ESock::CSubConnectionProviderFactoryBase& aFactory); |
96 static CDummySubConnectionProvider* NewL(ESock::CSubConnectionProviderFactoryBase& aFactory); |
97 CDummySubConnectionProvider(ESock::CSubConnectionProviderFactoryBase& aFactory); |
97 static CDummySubConnectionProvider* NewVanillaL(ESock::CSubConnectionProviderFactoryBase& aFactory); |
|
98 |
|
99 CDummySubConnectionProvider(ESock::CSubConnectionProviderFactoryBase& aFactory, const MeshMachine::TNodeActivityMap& aActivityMap); |
98 |
100 |
99 private: |
101 private: |
100 TBool incomingStatus; |
102 TBool incomingStatus; |
101 }; |
103 }; |
|
104 |
|
105 |
102 class CDummyExtendedSubConnectionProvider : public CCoreSubConnectionProvider |
106 class CDummyExtendedSubConnectionProvider : public CCoreSubConnectionProvider |
103 /** |
107 /** |
104 This dummy is intended to create flow shim based layer beneath it during its own creation |
108 This dummy is intended to create flow shim based layer beneath it during its own creation |
105 so that CTransportFlowShim is available to CSocket after the flow request has been created. |
109 so that CTransportFlowShim is available to CSocket after the flow request has been created. |
106 |
110 |
132 void Received(MeshMachine::TNodeContextBase& aContext); |
136 void Received(MeshMachine::TNodeContextBase& aContext); |
133 void ReceivedL(const Messages::TRuntimeCtxId& aSender, const Messages::TNodeId& aRecipient, Messages::TSignatureBase& aMessage); |
137 void ReceivedL(const Messages::TRuntimeCtxId& aSender, const Messages::TNodeId& aRecipient, Messages::TSignatureBase& aMessage); |
134 |
138 |
135 private: |
139 private: |
136 TBool incomingStatus; |
140 TBool incomingStatus; |
137 TFlowParams iFlowParams; |
141 ESock::TFlowParams iFlowParams; |
138 }; |
142 }; |
139 } |
143 |
140 |
144 |
141 namespace DummySCPRStates |
145 namespace DummySCPRStates |
142 { |
146 { |
143 typedef MeshMachine::TNodeContext<ESock::CDummySubConnectionProvider, SCprStates::TContext> TContext; |
147 typedef MeshMachine::TNodeContext<CDummySubConnectionProvider, SCprStates::TContext> TContext; |
144 |
148 |
145 DECLARE_SMELEMENT_HEADER( TRaiseGranted, MeshMachine::TStateTransition<TContext>, NetStateMachine::MStateTransition, DummySCPRStates::TContext ) |
149 DECLARE_SMELEMENT_HEADER( TRaiseGranted, MeshMachine::TStateTransition<TContext>, NetStateMachine::MStateTransition, DummySCPRStates::TContext ) |
146 virtual void DoL(); |
150 virtual void DoL(); |
147 DECLARE_SMELEMENT_FOOTER( TRaiseGranted ) |
151 DECLARE_SMELEMENT_FOOTER( TRaiseGranted ) |
148 |
152 |
151 DECLARE_SMELEMENT_FOOTER( TAwaitingReBindTo ) |
155 DECLARE_SMELEMENT_FOOTER( TAwaitingReBindTo ) |
152 |
156 |
153 DECLARE_SMELEMENT_HEADER( TAwaitingBrokenStart, MeshMachine::TState<TContext>, NetStateMachine::MState, TContext ) |
157 DECLARE_SMELEMENT_HEADER( TAwaitingBrokenStart, MeshMachine::TState<TContext>, NetStateMachine::MState, TContext ) |
154 virtual TBool Accept(); |
158 virtual TBool Accept(); |
155 DECLARE_SMELEMENT_FOOTER( TAwaitingBrokenStart ) |
159 DECLARE_SMELEMENT_FOOTER( TAwaitingBrokenStart ) |
|
160 |
|
161 DECLARE_SMELEMENT_HEADER( TRebindSelf, MeshMachine::TStateTransition<TContext>, NetStateMachine::MStateTransition, DummySCPRStates::TContext ) |
|
162 virtual void DoL(); |
|
163 DECLARE_SMELEMENT_FOOTER( TRebindSelf ) |
|
164 |
|
165 |
|
166 |
|
167 |
|
168 |
|
169 struct TWaitForBindToMutex |
|
170 { |
|
171 static TBool IsBlocked(const MeshMachine::TNodeContextBase& aContext) |
|
172 { |
|
173 return aContext.iNode.CountActivities(ESock::ECFActivityBindTo) == 0; |
|
174 } |
|
175 }; |
|
176 |
|
177 struct TWaitForNoDataClients |
|
178 { |
|
179 static TBool IsBlocked(const MeshMachine::TNodeContextBase& aContext) |
|
180 { |
|
181 return aContext.iNode.GetFirstClient<Messages::TDefaultClientMatchPolicy>(Messages::TClientType(ESock::TCFClientType::EData)) != NULL; |
|
182 } |
|
183 }; |
|
184 |
|
185 DECLARE_SERIALIZABLE_STATE( |
|
186 TNoTagWaitForBindTo, |
|
187 TWaitForBindToMutex, |
|
188 MeshMachine::TNoTag |
|
189 ) |
|
190 |
|
191 DECLARE_SERIALIZABLE_STATE( |
|
192 TNoTagWaitNoDataClients, |
|
193 TWaitForNoDataClients, |
|
194 MeshMachine::TNoTag |
|
195 ) |
|
196 |
|
197 |
|
198 |
|
199 DECLARE_SMELEMENT_HEADER( TCancelPreviousSelfRequest, MeshMachine::TStateTransition<TContext>, NetStateMachine::MStateTransition, DummySCPRStates::TContext ) |
|
200 virtual void DoL(); |
|
201 DECLARE_SMELEMENT_FOOTER( TCancelPreviousSelfRequest ) |
|
202 |
|
203 class CrazyIdle : public MeshMachine::CNodeRetryActivity |
|
204 { |
|
205 public: |
|
206 DECLARE_SMELEMENT_HEADER( TAwaitingCancelled, MeshMachine::TState<TContext>, NetStateMachine::MState, TContext ) |
|
207 virtual TBool Accept(); |
|
208 DECLARE_SMELEMENT_FOOTER( TAwaitingCancelled ) |
|
209 |
|
210 static MeshMachine::CNodeActivityBase* CrazyIdle::NewL( const MeshMachine::TNodeActivity& aActivitySig, MeshMachine::AMMNodeBase& aNode ); |
|
211 protected: |
|
212 CrazyIdle( const MeshMachine::TNodeActivity& aActivitySig, MeshMachine::AMMNodeBase& aNode ) |
|
213 :MeshMachine::CNodeRetryActivity(aActivitySig, aNode) |
|
214 {}; |
|
215 private: |
|
216 ~CrazyIdle(); |
|
217 }; |
156 |
218 |
157 DECLARE_ACTIVITY_MAP(stateMap) |
219 DECLARE_ACTIVITY_MAP(stateMap) |
158 } // namespace DummyCPRStates |
220 } // namespace DummyCPRStates |
159 |
221 |
160 namespace DummyExtendedSCPRStates |
222 namespace DummyExtendedSCPRStates |
161 { |
223 { |
162 typedef MeshMachine::TNodeContext<ESock::CDummyExtendedSubConnectionProvider, SCprStates::TContext> TContext; |
224 typedef MeshMachine::TNodeContext<CDummyExtendedSubConnectionProvider, SCprStates::TContext> TContext; |
163 |
225 |
164 DECLARE_SMELEMENT_HEADER( TAwaitingBinderResponse, MeshMachine::TState<TContext>, NetStateMachine::MState, TContext ) |
226 DECLARE_SMELEMENT_HEADER( TAwaitingBinderResponse, MeshMachine::TState<TContext>, NetStateMachine::MState, TContext ) |
165 virtual TBool Accept(); |
227 virtual TBool Accept(); |
166 DECLARE_SMELEMENT_FOOTER( TAwaitingBinderResponse ) |
228 DECLARE_SMELEMENT_FOOTER( TAwaitingBinderResponse ) |
167 |
229 |
217 { |
279 { |
218 iFlowParameters.Close(); |
280 iFlowParameters.Close(); |
219 } |
281 } |
220 iFlowParameters.Open(aFlowParameters); |
282 iFlowParameters.Open(aFlowParameters); |
221 } |
283 } |
222 typedef MeshMachine::TNodeContext<ESock::CDummyExtendedSubConnectionProvider, SCprStates::TContext> TContext; |
284 typedef MeshMachine::TNodeContext<CDummyExtendedSubConnectionProvider, SCprStates::TContext> TContext; |
223 |
285 |
224 static MeshMachine::CNodeActivityBase* CDummyBuildStackActivity::NewL( const MeshMachine::TNodeActivity& aActivitySig, MeshMachine::AMMNodeBase& aNode ); |
286 static MeshMachine::CNodeActivityBase* CDummyBuildStackActivity::NewL( const MeshMachine::TNodeActivity& aActivitySig, MeshMachine::AMMNodeBase& aNode ); |
225 |
287 |
226 protected: |
288 protected: |
227 CDummyBuildStackActivity(const MeshMachine::TNodeActivity& aActivitySig, MeshMachine::AMMNodeBase& aNode, TUint aNextActivityCount); |
289 CDummyBuildStackActivity(const MeshMachine::TNodeActivity& aActivitySig, MeshMachine::AMMNodeBase& aNode, TUint aNextActivityCount); |