datacommsserver/esockserver/core_states/ss_corepractivities.h
branchRCL_3
changeset 12 8b5d60ce1e94
parent 1 21d2ab05f085
child 17 9ddb1d67ebaf
equal deleted inserted replaced
11:98a7181d2ce7 12:8b5d60ce1e94
    12 //
    12 //
    13 // Description:
    13 // Description:
    14 // Core PR Activities
    14 // Core PR Activities
    15 //
    15 //
    16 //
    16 //
    17 
       
    18 /**
    17 /**
    19  @file
    18  @file
    20  @internalComponent
    19  @internalComponent
    21 */
    20 */
    22 
    21 
    25 
    24 
    26 #include <comms-infras/ss_coreprstates.h>
    25 #include <comms-infras/ss_coreprstates.h>
    27 #include <comms-infras/ss_mmnode.h>
    26 #include <comms-infras/ss_mmnode.h>
    28 #include <comms-infras/ss_nodemessages_internal.h>
    27 #include <comms-infras/ss_nodemessages_internal.h>
    29 #include <comms-infras/ss_nodemessages_legacy.h>
    28 #include <comms-infras/ss_nodemessages_legacy.h>
       
    29 #include <comms-infras/ss_internal_activities.h>
    30 
    30 
    31 #include <elements/mm_states.h>
    31 #include <elements/mm_states.h>
    32 #include <comms-infras/ss_parameterfamilybundle.h>
    32 #include <comms-infras/ss_parameterfamilybundle.h>
    33 #include <elements/nm_messages_internal.h>
    33 #include <elements/nm_messages_internal.h>
    34 
       
    35 
    34 
    36 namespace CoreErrorActivity
    35 namespace CoreErrorActivity
    37 { //If found in node activity map is ran by the MM whenewer an error is received
    36 { //If found in node activity map is ran by the MM whenewer an error is received
    38   //and not processed by its target activity
    37   //and not processed by its target activity
    39 	DECLARE_EXPORT_NODEACTIVITY(CoreError)
    38 	DECLARE_EXPORT_NODEACTIVITY(CoreError)
    50 }
    49 }
    51 
    50 
    52 namespace PRClientLeaveActivity
    51 namespace PRClientLeaveActivity
    53 { //This activity does not need the activity object
    52 { //This activity does not need the activity object
    54 	DECLARE_EXPORT_NODEACTIVITY(PRClientLeave)
    53 	DECLARE_EXPORT_NODEACTIVITY(PRClientLeave)
       
    54 }
       
    55 
       
    56 namespace PRClientLeftActivity
       
    57 { //This activity does not need the activity object
       
    58 	DECLARE_EXPORT_NODEACTIVITY(PRClientLeft)
    55 }
    59 }
    56 
    60 
    57 namespace PRDataClientIdleActivity
    61 namespace PRDataClientIdleActivity
    58 { //TAwaitingDataClientIdle will only accept if no more clients joined to the node
    62 { //TAwaitingDataClientIdle will only accept if no more clients joined to the node
    59 	static const TInt KDataClientNotStarted = 1;		// idle data client is not started
    63 	static const TInt KDataClientNotStarted = 1;		// idle data client is not started
   170 	{
   174 	{
   171 public:
   175 public:
   172     IMPORT_C static MeshMachine::CNodeActivityBase* New(const MeshMachine::TNodeActivity& aActivitySig, MeshMachine::AMMNodeBase& aNode);
   176     IMPORT_C static MeshMachine::CNodeActivityBase* New(const MeshMachine::TNodeActivity& aActivitySig, MeshMachine::AMMNodeBase& aNode);
   173 
   177 
   174 protected:
   178 protected:
   175 	CDestroyActivity(const MeshMachine::TNodeActivity& aActivitySig, MeshMachine::AMMNodeBase& aNode);
   179     CDestroyActivity(const MeshMachine::TNodeActivity& aActivitySig, MeshMachine::AMMNodeBase& aNode);
   176 	virtual void Destroy();
   180     virtual void Destroy();
   177 	virtual TBool Next(MeshMachine::TNodeContextBase& aContext);
       
   178 
   181 
   179 //States, StateForks & StateTransitions
   182 //States, StateForks & StateTransitions
   180 protected:
   183 protected:
   181 	typedef CoreStates::TContext TContext;
   184 	typedef CoreStates::TContext TContext;
   182 
   185 
   195 		TProcessClientLeave,
   198 		TProcessClientLeave,
   196 		MeshMachine::TRemoveClient,
   199 		MeshMachine::TRemoveClient,
   197 		CoreNetStates::TSendLeaveCompleteIfRequest
   200 		CoreNetStates::TSendLeaveCompleteIfRequest
   198 		)
   201 		)
   199 
   202 
   200 	typedef MeshMachine::TActivitiesIdMutex<ESock::ECFActivityStop, ESock::ECFActivityStopDataClient, ESock::ECFActivityDataClientGoneDown, ESock::ECFActivityGoneDown> TAllStopActivityMutex;
   203 	typedef MeshMachine::TActivitiesIdMutex<ESock::ECFActivityStop, ESock::ECFActivityStopDataClient, ESock::ECFActivityDataClientGoneDown, ESock::ECFActivityGoneDown, ESock::ECFActivityDestroyOrphans> TAllStopActivityMutex;
   201 	typedef MeshMachine::TActivityIdMutex<ESock::ECFActivityClientLeave> TClientLeaveMutex;
   204 	typedef MeshMachine::TActivityIdMutex<ESock::ECFActivityClientLeave> TClientLeaveMutex;
   202     typedef MeshMachine::TClientMutex<Messages::TDefaultClientMatchPolicy, ESock::TCFClientType::EData, ESock::TCFClientType::ELeaving> TLeavingDataClientMutex;
   205     typedef MeshMachine::TClientMutex<Messages::TDefaultClientMatchPolicy, ESock::TCFClientType::EData, ESock::TCFClientType::ELeaving> TLeavingDataClientMutex;
   203 	typedef MeshMachine::TAggregatedMutex_OR<TAllStopActivityMutex, TLeavingDataClientMutex> TAllStopActivityOrLeavingDataClientMutex;
   206 	typedef MeshMachine::TAggregatedMutex_OR<TAllStopActivityMutex, TLeavingDataClientMutex> TAllStopActivityOrLeavingDataClientMutex;
   204 	typedef MeshMachine::TAggregatedMutex_OR<TAllStopActivityOrLeavingDataClientMutex, TClientLeaveMutex> TAllStopActivityOrLeavingDataClientOrClientLeaveMutex;
   207 	typedef MeshMachine::TAggregatedMutex_OR<TAllStopActivityOrLeavingDataClientMutex, TClientLeaveMutex> TAllStopActivityOrLeavingDataClientOrClientLeaveMutex;
   205 
   208 
   214 	Private NewL with no implementation to hide the CNodeActivityBase::NewL
   217 	Private NewL with no implementation to hide the CNodeActivityBase::NewL
   215 	Creation of preallocated activities doesn't fail and hence a non-leaving ::New should be used instead*/
   218 	Creation of preallocated activities doesn't fail and hence a non-leaving ::New should be used instead*/
   216     static MeshMachine::CNodeActivityBase* NewL(const MeshMachine::TNodeActivity& aActivitySig, MeshMachine::AMMNodeBase& aNode);
   219     static MeshMachine::CNodeActivityBase* NewL(const MeshMachine::TNodeActivity& aActivitySig, MeshMachine::AMMNodeBase& aNode);
   217 	};
   220 	};
   218 
   221 
       
   222 //-=========================================================
       
   223 //
       
   224 // DestroyOrphans Activity - will delete the node when destructed
       
   225 // if TMarkNodeForDestruction tuple has been called.
       
   226 //
       
   227 //-=========================================================
       
   228 
       
   229 NONSHARABLE_CLASS(CDestroyOrphansActivity) : public MeshMachine::CNodeActivityBase, protected MeshMachine::APreallocatedOriginators<1>
       
   230     {
       
   231 public:
       
   232     typedef PRStates::TContext TContext;
       
   233 
       
   234     static CNodeActivityBase* New( const MeshMachine::TNodeActivity& aActivitySig, MeshMachine::AMMNodeBase& aNode );
       
   235     void SetDestroyFlag();
       
   236     TBool DestroyFlag() const;
       
   237 
       
   238     DECLARE_SMELEMENT_HEADER( TMarkNodeForDestruction, MeshMachine::TStateTransition<TContext>, NetStateMachine::MStateTransition, TContext )
       
   239         virtual void DoL();
       
   240     DECLARE_SMELEMENT_FOOTER( TMarkNodeForDestruction )
       
   241 
       
   242     DECLARE_SMELEMENT_HEADER( TNoTagOrNoTagBackwards, MeshMachine::TStateFork<TContext>, NetStateMachine::MStateFork, TContext )
       
   243         virtual TInt TransitionTag();
       
   244     DECLARE_SMELEMENT_FOOTER( TNoTagOrNoTagBackwards )
       
   245 
       
   246     DECLARE_SMELEMENT_HEADER( TNoTagOrNoClients, MeshMachine::TStateFork<TContext>, NetStateMachine::MStateFork, TContext )
       
   247         virtual TInt TransitionTag();
       
   248     DECLARE_SMELEMENT_FOOTER( TNoTagOrNoClients )
       
   249 
       
   250     DECLARE_SMELEMENT_HEADER( TControlProviderNoTagOrNoClients, MeshMachine::TStateFork<TContext>, NetStateMachine::MStateFork, TContext )
       
   251         virtual TInt TransitionTag();
       
   252     DECLARE_SMELEMENT_FOOTER( TControlProviderNoTagOrNoClients )
       
   253 
       
   254     ~CDestroyOrphansActivity();
       
   255 
       
   256 protected:
       
   257     explicit CDestroyOrphansActivity(const MeshMachine::TNodeActivity& aActivitySig, MeshMachine::AMMNodeBase& aNode);
       
   258     virtual void Destroy();
       
   259 
       
   260 private:
       
   261     TBool iDestroyFlag;         // whether to destroy node on destruction of activity
       
   262     };
   219 
   263 
   220 //-=========================================================
   264 //-=========================================================
   221 //
   265 //
   222 //Looping Activity
   266 //Looping Activity
   223 //
   267 //
   285 //Binding Activity
   329 //Binding Activity
   286 //
   330 //
   287 //-=========================================================
   331 //-=========================================================
   288 class ABindingActivity
   332 class ABindingActivity
   289 /*
   333 /*
   290 The interface must be implemented by activities featuring (using) PRStates::TSendBindToComplete.
   334 ABindingActivity is a helper class for activities requesting binders (sending TCFServiceProvider::TCommsBinderRequest) and, 
   291 ABindingActivity can store the activityId and the originator expecting intermediate
   335 following consumption of the binder, needing to respond to the recipient of TCFServiceProvider::TCommsBinderRequest with 
   292 TBindToComplete. The originator might have sent either a TBindTo or TCommsBinderResponse.
   336 TCFServiceProvider::TBindToComplete as implied by the TCFServiceProvider::TCommsBinderRequest protocol. Such activities, 
       
   337 after they receive TCFServiceProvider::TCommsBinderResponse need to remember the TNodeCtxId of the sender in order to 
       
   338 correctly respond with TCFServiceProvider::TBindToComplete. They can remember the sender of 
       
   339 TCFServiceProvider::TCommsBinderResponse by calling ABindingActivity::StoreOriginator and subsequently respond by using 
       
   340 ABindingActivity::TSendBindToComplete.
   293 */
   341 */
   294 	{
   342 	{
   295 public:
   343 public:
   296     static const TInt KInterfaceId = 0x102864DD;
   344     static const TInt KInterfaceId = 0x102864DD;
   297     IMPORT_C void StoreOriginator(const Messages::TRuntimeCtxId& aNodeCtxId);
   345     IMPORT_C void StoreOriginator(const Messages::TRuntimeCtxId& aNodeCtxId);
   321 
   369 
   322 public:
   370 public:
   323     EXPORT_DECLARE_SMELEMENT_HEADER( TSendBindToComplete, MeshMachine::TStateTransition<TContext>, NetStateMachine::MStateTransition, TContext )
   371     EXPORT_DECLARE_SMELEMENT_HEADER( TSendBindToComplete, MeshMachine::TStateTransition<TContext>, NetStateMachine::MStateTransition, TContext )
   324     	IMPORT_C virtual void DoL();
   372     	IMPORT_C virtual void DoL();
   325     DECLARE_SMELEMENT_FOOTER( TSendBindToComplete )
   373     DECLARE_SMELEMENT_FOOTER( TSendBindToComplete )
   326 
   374     
   327     EXPORT_DECLARE_SMELEMENT_HEADER( TSendBindToCompleteIfExpected, MeshMachine::TStateTransition<TContext>, NetStateMachine::MStateTransition, TContext )
       
   328     	IMPORT_C virtual void DoL();
       
   329     DECLARE_SMELEMENT_FOOTER( TSendBindToCompleteIfExpected )
       
   330 
       
   331     DECLARE_AGGREGATED_TRANSITION2(
       
   332         TSendBindToCompleteAndRequestCommsBinder,
       
   333         TSendBindToComplete,
       
   334         CoreNetStates::TRequestCommsBinder
       
   335         )
       
   336 	};
   375 	};
   337 
   376 
   338 } //namespace CoreActivities
   377 } //namespace CoreActivities
   339 
   378 
   340 
   379