commsfwsupport/commselements/meshmachine/inc/mm_activities.h
branchRCL_3
changeset 23 cbb19216b74d
parent 18 9644881fedd0
equal deleted inserted replaced
21:07656293a99c 23:cbb19216b74d
    89 @see DEFINE_CUSTOM_NODEACTIVITY
    89 @see DEFINE_CUSTOM_NODEACTIVITY
    90 */
    90 */
    91 	#define DEFINE_EXPORT_CUSTOM_NODEACTIVITY( id, name, msgtype, ctor ) \
    91 	#define DEFINE_EXPORT_CUSTOM_NODEACTIVITY( id, name, msgtype, ctor ) \
    92 		EXPORT_C const MeshMachine::TNodeActivity& name :: Self() {return iSelf;} \
    92 		EXPORT_C const MeshMachine::TNodeActivity& name :: Self() {return iSelf;} \
    93 		EXPORT_C const NetStateMachine::TStateTriple& name :: FirstTriple() {return iData[1];} \
    93 		EXPORT_C const NetStateMachine::TStateTriple& name :: FirstTriple() {return iData[1];} \
    94 		const MeshMachine::TNodeActivity name :: iSelf = {id, 0, msgtype::EId, msgtype::ERealm, name :: iData[1], (TAny*)&ctor, _S8(#name)}; \
    94 		const MeshMachine::TNodeActivity name :: iSelf = {id, MeshMachine::TNodeActivity::ENodeCtor, msgtype::EId, msgtype::ERealm, name :: iData[1], (TAny*)&ctor, _S8(#name)}; \
    95 		DEFINE_TRIPLES_TABLE( name :: iData )
    95 		DEFINE_TRIPLES_TABLE( name :: iData )
    96 
    96 
    97 /**
    97 /**
    98 Define a custom node activity. A custom node activity is a node activity which defines its own
    98 Define a custom node activity. A custom node activity is a node activity which defines its own
    99 node activity class. This is used, for example, if the activity wishes to share some custom context
    99 node activity class. This is used, for example, if the activity wishes to share some custom context
   108 
   108 
   109 @see DEFINE_NODEACTIVITY
   109 @see DEFINE_NODEACTIVITY
   110 @see CNodeActivityBase
   110 @see CNodeActivityBase
   111 */
   111 */
   112 	#define DEFINE_CUSTOM_NODEACTIVITY( id, name, msgtype, ctor ) \
   112 	#define DEFINE_CUSTOM_NODEACTIVITY( id, name, msgtype, ctor ) \
   113 		const MeshMachine::TNodeActivity name :: iSelf = {id, 0, msgtype::EId, msgtype::ERealm, name :: iData[1], (TAny*)&ctor, _S8(#name)}; \
   113 		const MeshMachine::TNodeActivity name :: iSelf = {id, MeshMachine::TNodeActivity::ENodeCtor, msgtype::EId, msgtype::ERealm, name :: iData[1], (TAny*)&ctor, _S8(#name)}; \
   114 		DEFINE_TRIPLES_TABLE( name :: iData )
   114 		DEFINE_TRIPLES_TABLE( name :: iData )
   115 
   115 
   116 #else
   116 #else
   117 
   117 
   118 /**
   118 /**
   126 @see DEFINE_CUSTOM_NODEACTIVITY
   126 @see DEFINE_CUSTOM_NODEACTIVITY
   127 */
   127 */
   128 	#define DEFINE_EXPORT_CUSTOM_NODEACTIVITY( id, name, msgtype, ctor ) \
   128 	#define DEFINE_EXPORT_CUSTOM_NODEACTIVITY( id, name, msgtype, ctor ) \
   129 		EXPORT_C const MeshMachine::TNodeActivity& name :: Self() {return iSelf;} \
   129 		EXPORT_C const MeshMachine::TNodeActivity& name :: Self() {return iSelf;} \
   130 		EXPORT_C const NetStateMachine::TStateTriple& name :: FirstTriple() {return iData[1];} \
   130 		EXPORT_C const NetStateMachine::TStateTriple& name :: FirstTriple() {return iData[1];} \
   131 		const MeshMachine::TNodeActivity name :: iSelf = {id, 0, msgtype::EId, msgtype::ERealm, name :: iData[1], (TAny*)&ctor, NULL}; \
   131 		const MeshMachine::TNodeActivity name :: iSelf = {id, MeshMachine::TNodeActivity::ENodeCtor, msgtype::EId, msgtype::ERealm, name :: iData[1], (TAny*)&ctor, NULL}; \
   132 		DEFINE_TRIPLES_TABLE( name :: iData )
   132 		DEFINE_TRIPLES_TABLE( name :: iData )
   133 
   133 
   134 /**
   134 /**
   135 Define a custom node activity. A custom node activity is a node activity which defines its own
   135 Define a custom node activity. A custom node activity is a node activity which defines its own
   136 node activity class. This is used, for example, if the activity wishes to share some custom context
   136 node activity class. This is used, for example, if the activity wishes to share some custom context
   145 
   145 
   146 @see DEFINE_NODEACTIVITY
   146 @see DEFINE_NODEACTIVITY
   147 @see CNodeActivityBase
   147 @see CNodeActivityBase
   148 */
   148 */
   149 	#define DEFINE_CUSTOM_NODEACTIVITY( id, name, msgtype, ctor ) \
   149 	#define DEFINE_CUSTOM_NODEACTIVITY( id, name, msgtype, ctor ) \
   150 		const MeshMachine::TNodeActivity name :: iSelf = {id, 0, msgtype::EId, msgtype::ERealm, name :: iData[1], (TAny*)&ctor, NULL}; \
   150 		const MeshMachine::TNodeActivity name :: iSelf = {id, MeshMachine::TNodeActivity::ENodeCtor, msgtype::EId, msgtype::ERealm, name :: iData[1], (TAny*)&ctor, NULL}; \
   151 		DEFINE_TRIPLES_TABLE( name :: iData )
   151 		DEFINE_TRIPLES_TABLE( name :: iData )
   152 
   152 
   153 #endif
   153 #endif
   154 
   154 
   155 /**
   155 /**
   474 @see DEFINE_RESERVED_NODEACTIVITY
   474 @see DEFINE_RESERVED_NODEACTIVITY
   475 @see CNodeActivityBase
   475 @see CNodeActivityBase
   476 	
   476 	
   477 */
   477 */
   478 	#define DEFINE_RESERVED_CUSTOM_NODEACTIVITY( id, name, msgtype, ctor ) \
   478 	#define DEFINE_RESERVED_CUSTOM_NODEACTIVITY( id, name, msgtype, ctor ) \
   479 		const MeshMachine::TNodeActivity name :: iSelf = {id, 1, msgtype::EId, msgtype::ERealm, name :: iData[1], (TAny*)&ctor, _S8(#name)}; \
   479 		const MeshMachine::TNodeActivity name :: iSelf = {id, MeshMachine::TNodeActivity::EContextCtor, msgtype::EId, msgtype::ERealm, name :: iData[1], (TAny*)&ctor, _S8(#name)}; \
   480 		DEFINE_TRIPLES_TABLE( name :: iData )
   480 		DEFINE_TRIPLES_TABLE( name :: iData )
   481 
   481 
   482 #else
   482 #else
   483 
   483 
   484 /**
   484 /**
   492 @see DEFINE_RESERVED_CUSTOM_NODEACTIVITY
   492 @see DEFINE_RESERVED_CUSTOM_NODEACTIVITY
   493 */
   493 */
   494 	#define DEFINE_RESERVED_EXPORT_CUSTOM_NODEACTIVITY( id, name, msgtype, ctor ) \
   494 	#define DEFINE_RESERVED_EXPORT_CUSTOM_NODEACTIVITY( id, name, msgtype, ctor ) \
   495 		EXPORT_C const MeshMachine::TNodeActivity& name :: Self() {return iSelf;} \
   495 		EXPORT_C const MeshMachine::TNodeActivity& name :: Self() {return iSelf;} \
   496 		EXPORT_C const NetStateMachine::TStateTriple& name :: FirstTriple() {return iData[1];} \
   496 		EXPORT_C const NetStateMachine::TStateTriple& name :: FirstTriple() {return iData[1];} \
   497 		const MeshMachine::TNodeActivity name :: iSelf = {id, 1, msgtype::EId, msgtype::ERealm, name :: iData[1], (TAny*)&ctor, NULL}; \
   497 		const MeshMachine::TNodeActivity name :: iSelf = {id, MeshMachine::TNodeActivity::EContextCtor, msgtype::EId, msgtype::ERealm, name :: iData[1], (TAny*)&ctor, NULL}; \
   498 		DEFINE_TRIPLES_TABLE( name :: iData )
   498 		DEFINE_TRIPLES_TABLE( name :: iData )
   499 
   499 
   500 /**
   500 /**
   501 Define a custom node activity. A custom node activity is a node activity which defines its own
   501 Define a custom node activity. A custom node activity is a node activity which defines its own
   502 node activity class. This is used, for example, if the activity wishes to share some custom context
   502 node activity class. This is used, for example, if the activity wishes to share some custom context
   511 
   511 
   512 @see DEFINE_RESERVED_NODEACTIVITY
   512 @see DEFINE_RESERVED_NODEACTIVITY
   513 @see CNodeActivityBase
   513 @see CNodeActivityBase
   514 */
   514 */
   515 	#define DEFINE_RESERVED_CUSTOM_NODEACTIVITY( id, name, msgtype, ctor ) \
   515 	#define DEFINE_RESERVED_CUSTOM_NODEACTIVITY( id, name, msgtype, ctor ) \
   516 		const MeshMachine::TNodeActivity name :: iSelf = {id, 1, msgtype::EId, msgtype::ERealm, name :: iData[1], (TAny*)&ctor, NULL}; \
   516 		const MeshMachine::TNodeActivity name :: iSelf = {id, MeshMachine::TNodeActivity::EContextCtor, msgtype::EId, msgtype::ERealm, name :: iData[1], (TAny*)&ctor, NULL}; \
   517 		DEFINE_TRIPLES_TABLE( name :: iData )
   517 		DEFINE_TRIPLES_TABLE( name :: iData )
   518 
   518 
   519 #endif
   519 #endif
   520 
   520 
   521 /**
   521 /**
   926 
   926 
   927 	/**
   927 	/**
   928 	All the nodes that have started the same activity
   928 	All the nodes that have started the same activity
   929 	*/
   929 	*/
   930 	RArray<Messages::XNodePeerId> iOriginators;
   930 	RArray<Messages::XNodePeerId> iOriginators;
   931 
   931 /*	class TOriginatorStore
       
   932 		{
       
   933 	private:
       
   934 		typedef Messages::XNodePeerId TOriginatorType;
       
   935 	public:
       
   936 		class Iterator
       
   937 			{
       
   938 		public:
       
   939 			Iterator(const TOriginatorStore& aOriginatorStore);
       
   940 			TOriginatorType* operator++();
       
   941 			operator*();
       
   942 			};
       
   943 		virtual TInt Count() const {return iOriginators.Count();}
       
   944 		virtual const TOriginatorType& operator[](TUint aIndex) const {return iOriginators[aIndex];};
       
   945 		virtual TInt Append(const Messages::RNodeInterface& aInterface);
       
   946 		virtual TInt Remove(const Messages::RNodeInterface& aInterface);
       
   947 	private:
       
   948 		RArray<TOriginatorType> iOriginators;
       
   949 		} iOriginators;
       
   950 */
   932 private: //Shouldn't be accessed directly
   951 private: //Shouldn't be accessed directly
   933 	TInt     iError;    //Risk of failure is a generic property of an activity.
   952 	TInt     iError;    //Risk of failure is a generic property of an activity.
   934 	                    //Activities may choose to use external error handling activities,
   953 	                    //Activities may choose to use external error handling activities,
   935 	                    //or may choose to handle errors locally. In the latter case,
   954 	                    //or may choose to handle errors locally. In the latter case,
   936 	                    //the activity may want to know it's running an error mode
   955 	                    //the activity may want to know it's running an error mode
  1540 //-=========================================================
  1559 //-=========================================================
  1541 //
  1560 //
  1542 // CPreallocatedNodeActivityBase
  1561 // CPreallocatedNodeActivityBase
  1543 //
  1562 //
  1544 //-=========================================================
  1563 //-=========================================================
  1545 template <TInt ORIGINATORSCOUNT>
  1564 // APreallocatedOriginators is primed with 2 as the vast majority of Activities will have a maximum of 2 originators.
       
  1565 // Corner cases should be handled seperately. For example CDestroyActivity has its own implementation as it will only ever have 1 originator
  1546 class CPreallocatedNodeRetryActivity : public MeshMachine::CNodeRetryActivity,
  1566 class CPreallocatedNodeRetryActivity : public MeshMachine::CNodeRetryActivity,
  1547                                       protected MeshMachine::APreallocatedOriginators<ORIGINATORSCOUNT>
  1567                                       protected MeshMachine::APreallocatedOriginators<2>
  1548 /**
  1568 /**
  1549 @internalTechnology
  1569 @internalTechnology
  1550 */
  1570 */
  1551 	{
  1571 	{
  1552 public:
  1572 public:
  1559     	}
  1579     	}
  1560 
  1580 
  1561 protected:
  1581 protected:
  1562 	CPreallocatedNodeRetryActivity(const MeshMachine::TNodeActivity& aActivitySig, MeshMachine::AMMNodeBase& aNode)
  1582 	CPreallocatedNodeRetryActivity(const MeshMachine::TNodeActivity& aActivitySig, MeshMachine::AMMNodeBase& aNode)
  1563 	:	CNodeRetryActivity(aActivitySig, aNode),
  1583 	:	CNodeRetryActivity(aActivitySig, aNode),
  1564 		APreallocatedOriginators<ORIGINATORSCOUNT>(iOriginators)
  1584 		APreallocatedOriginators<2>(iOriginators)
  1565 		{
  1585 		{
  1566 		}
  1586 		}
  1567 
  1587 
  1568 	virtual void Destroy()
  1588 	virtual void Destroy()
  1569 		{
  1589 		{
  1582     {
  1602     {
  1583     //Historical. Method ceased to leave, but must keep the old, L-ending overload.
  1603     //Historical. Method ceased to leave, but must keep the old, L-ending overload.
  1584     return GetNextActivityCount(aActivitySig, aNode);
  1604     return GetNextActivityCount(aActivitySig, aNode);
  1585     }
  1605     }
  1586 
  1606 
       
  1607 //By default we reserve the space for preallocated activities generously, to fit even a synchronised activity preallocating space for up to 3 originators.
       
  1608 //Any node, hosting specific activities that may need the preallocation mechanism can choose a more optimal amounts.
       
  1609 //For efficiency reasons it is strongly recommended that any node (or family of nodes) is revisited and an optimal
       
  1610 //amount of space is specified (could be specified in the base class for those nodes or in every type of node separatelly).
       
  1611 static const TUint KDefaultMaxPreallocatedActivityCount = 3;
       
  1612 static const TUint KDefaultMaxPreallocatedActivitySize = sizeof(CNodeRetryParallelActivity) + sizeof(APreallocatedOriginators<3>);
       
  1613 static const TUint KDefaultPreallocatedActivityBufferSize = KDefaultMaxPreallocatedActivityCount * KDefaultMaxPreallocatedActivitySize;
       
  1614 
  1587 } //namespace MeshMachine
  1615 } //namespace MeshMachine
  1588 
  1616 
  1589 #endif //SYMBIAN_MM_ACTIVITIES_H
  1617 #endif //SYMBIAN_MM_ACTIVITIES_H
  1590 
  1618