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, msgtype::EId, msgtype::ERealm, name :: iData[1], &ctor, _S8(#name)}; \ |
94 const MeshMachine::TNodeActivity name :: iSelf = {id, 0, 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 |
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, msgtype::EId, msgtype::ERealm, name :: iData[1], &ctor, NULL}; \ |
131 const MeshMachine::TNodeActivity name :: iSelf = {id, 0, 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 |
415 NULL, \ |
415 NULL, \ |
416 NULL \ |
416 NULL \ |
417 }; |
417 }; |
418 |
418 |
419 /** |
419 /** |
|
420 RESERVED MACROS NOT TO BE USED. |
|
421 The following are new macro definitions allowing the context to be passed as a parameter rather than the node. |
|
422 In time the ability to pass context rather than node will be placed in the original macros. For the meantime, |
|
423 only critical commsFw activities which must have the context passed instead of the node should use these macros. |
|
424 All other activities should continue to use original macros declared above. |
|
425 */ |
|
426 /** |
|
427 Declare and export a node activity. |
|
428 |
|
429 @param name The name of the activity, which will be used to put it into the node's activity map |
|
430 |
|
431 @see DECLARE_NODEACTIVITY |
|
432 */ |
|
433 #define DECLARE_RESERVED_EXPORT_NODEACTIVITY( name ) \ |
|
434 struct name \ |
|
435 { \ |
|
436 IMPORT_C static const MeshMachine::TNodeActivity& Self(); \ |
|
437 IMPORT_C static const NetStateMachine::TStateTriple& FirstTriple(); \ |
|
438 static const MeshMachine::TNodeActivity iSelf; \ |
|
439 static const NetStateMachine::TStateTriple iData[]; \ |
|
440 }; |
|
441 |
|
442 /** |
|
443 Declares a node activity. A node activity is a state machine. It contains multiple nodeactivity |
|
444 entries, which respresent the states, transitions and forks of the state machine. |
|
445 |
|
446 @param name The name of the activity, which will be used to put it into the node's activity map |
|
447 |
|
448 @see DEFINE_NODEACTIVITY |
|
449 @see NODEACTIVITY_ENTRY |
|
450 */ |
|
451 #define DECLARE_RESERVED_NODEACTIVITY( name ) \ |
|
452 struct name \ |
|
453 { \ |
|
454 inline static const MeshMachine::TNodeActivity& Self() {return iSelf;} \ |
|
455 inline static const NetStateMachine::TStateTriple& FirstTriple() {return iData[1];} \ |
|
456 static const MeshMachine::TNodeActivity iSelf; \ |
|
457 static const NetStateMachine::TStateTriple iData[]; \ |
|
458 }; |
|
459 |
|
460 #ifdef SYMBIAN_TRACE_ENABLE |
|
461 |
|
462 /** |
|
463 Define a custom node activity. A custom node activity is a node activity which defines its own |
|
464 node activity class. This is used, for example, if the activity wishes to share some custom context |
|
465 information between the states and transition in the activity. |
|
466 |
|
467 Node activity class must derive from CNodeActivityBase. |
|
468 |
|
469 @param id Identifier for the activity |
|
470 @param name The name of the activity |
|
471 @param msgtype Message which will kickoff this activity |
|
472 @param ctor Constructor for the custom activity class |
|
473 |
|
474 @see DEFINE_RESERVED_NODEACTIVITY |
|
475 @see CNodeActivityBase |
|
476 |
|
477 */ |
|
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)}; \ |
|
480 DEFINE_TRIPLES_TABLE( name :: iData ) |
|
481 |
|
482 #else |
|
483 |
|
484 /** |
|
485 Define and export a custom node activity. |
|
486 |
|
487 @param id Identifier for the activity |
|
488 @param name The name of the activity |
|
489 @param msgtype Message which will kickoff this activity |
|
490 @param ctor Constructor for the custom activity class |
|
491 |
|
492 @see DEFINE_RESERVED_CUSTOM_NODEACTIVITY |
|
493 */ |
|
494 #define DEFINE_RESERVED_EXPORT_CUSTOM_NODEACTIVITY( id, name, msgtype, ctor ) \ |
|
495 EXPORT_C const MeshMachine::TNodeActivity& name :: Self() {return iSelf;} \ |
|
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}; \ |
|
498 DEFINE_TRIPLES_TABLE( name :: iData ) |
|
499 |
|
500 /** |
|
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 |
|
503 information between the states and transition in the activity. |
|
504 |
|
505 Node activity class must derive from CNodeActivityBase. |
|
506 |
|
507 @param id Identifier for the activity |
|
508 @param name The name of the activity |
|
509 @param msgtype Message which will kickoff this activity |
|
510 @param ctor Constructor for the custom activity class |
|
511 |
|
512 @see DEFINE_RESERVED_NODEACTIVITY |
|
513 @see CNodeActivityBase |
|
514 */ |
|
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}; \ |
|
517 DEFINE_TRIPLES_TABLE( name :: iData ) |
|
518 |
|
519 #endif |
|
520 |
|
521 /** |
|
522 Define and declare a custom node activity |
|
523 |
|
524 @param id Identifier for the activity |
|
525 @param name The name of the activity |
|
526 @param msgtype Message which will kickoff this activity |
|
527 @param ctor Constructor for the custom activity class |
|
528 |
|
529 @see DEFINE_RESERVED_CUSTOM_NODEACTIVITY |
|
530 */ |
|
531 #define DECLARE_DEFINE_RESERVED_CUSTOM_NODEACTIVITY( id, name, msgtype, ctor ) \ |
|
532 DECLARE_RESERVED_NODEACTIVITY( name ) \ |
|
533 DEFINE_RESERVED_CUSTOM_NODEACTIVITY( id, name, msgtype, ctor ) |
|
534 |
|
535 /** |
|
536 END OF RESERVED MACROS |
|
537 */ |
|
538 |
|
539 /** |
420 Mark the end of an activity map. This macro should be used for an activity map based |
540 Mark the end of an activity map. This macro should be used for an activity map based |
421 on other activity maps. |
541 on other activity maps. |
422 |
542 |
423 @param name_space The namespace of the base map |
543 @param name_space The namespace of the base map |
424 @param base_map The name of the base map |
544 @param base_map The name of the base map |
807 //iError must be cleared before the activity goes out of scope |
938 //iError must be cleared before the activity goes out of scope |
808 //to indicate the error has been handled. |
939 //to indicate the error has been handled. |
809 |
940 |
810 const TNodeActivity& iActivitySig; |
941 const TNodeActivity& iActivitySig; |
811 |
942 |
812 // Last node a message was sent to |
943 class RPostedToNodeOrPeer |
813 Messages::TNodeId iPostedToId; |
944 /* |
|
945 * Class is used to store the recipient of the last request sent from the 'this' |
|
946 * (the activity). This recipient can be represented either by its TNodeId address |
|
947 * or, if it's a peer of the local node, by RNodeInterface. |
|
948 * The implementation may seem awkward or overengineered. This is to protect binary |
|
949 * compatibility (it used to be TNodeId here and sizeof TNodeId was all there was at hand). |
|
950 * |
|
951 * Rules of the game are that RPostedToNodeOrPeer:iBuf is a shared dwelling for either: |
|
952 * - address of an RNodeInterface (in case posted to is a peer) |
|
953 * - TNodeId (in case posted to is not a peer) |
|
954 * Inspecting the content of iBuf and the assumptions around it are a little fragile |
|
955 * (based on TNodeId class layout a bit), so the code must be viligent. |
|
956 * _Node and _Peer perform arbitral happy conversion, so there can be 3 reasons why _Node()->Ptr() is NULL: |
|
957 * (1) iBuf stores a 4 byte ptr to RNodeInterface and what Ptr normally returns is beyond these 4 bytes in a land hopefully zeroed by ::Close |
|
958 * (2) iBuf stores nothing. |
|
959 * (3) iBuf stores a TNodeId pointing a NULL node (effectivelly TNodeId::NullId()). (3) is only theoretical as Open(TNodeId) prevens Ptr be NULL |
|
960 * Therefore it is safe to assume that if Ptr() is NULL, it is either a valid pointer to a peer or NULL. |
|
961 * Happily _Peer() will return that pointer or NULL respectivelly.* |
|
962 */ |
|
963 { |
|
964 private: |
|
965 typedef Messages::RNodeInterface* TPeerType; |
|
966 public: |
|
967 RPostedToNodeOrPeer(); |
|
968 void Open(const Messages::RNodeInterface& aPeer); |
|
969 void Open(const Messages::TNodeId& aNode); |
|
970 void Close(); |
|
971 |
|
972 const Messages::RNodeInterface* Peer() const; |
|
973 const Messages::TNodeId& NodeId() const; |
|
974 |
|
975 private: |
|
976 TPeerType* _Peer() |
|
977 { |
|
978 return reinterpret_cast<TPeerType*>(&iBuf[0]); |
|
979 } |
|
980 |
|
981 const TPeerType* _Peer() const |
|
982 { |
|
983 return reinterpret_cast<const TPeerType*>(&iBuf[0]); |
|
984 } |
|
985 |
|
986 Messages::TNodeId* _Node() |
|
987 { |
|
988 return reinterpret_cast<Messages::TNodeId*>(&iBuf[0]); |
|
989 } |
|
990 |
|
991 const Messages::TNodeId* _Node() const |
|
992 { |
|
993 return reinterpret_cast<const Messages::TNodeId*>(&iBuf[0]); |
|
994 } |
|
995 TUint8 iBuf[__Align8(sizeof(Messages::TNodeId))]; |
|
996 } iPostedToId; |
814 }; |
997 }; |
815 |
998 |
816 |
999 |
817 /** |
1000 /** |
818 Activity type that generates a unique activity id every time it is instantiated. |
1001 Activity type that generates a unique activity id every time it is instantiated. |
844 For use by custom activity NewLs to generate the unique part of the activity id. |
1027 For use by custom activity NewLs to generate the unique part of the activity id. |
845 @param aActivitySig Context information about how the activity is to be started |
1028 @param aActivitySig Context information about how the activity is to be started |
846 @param aNode The node to which this activity will belong. |
1029 @param aNode The node to which this activity will belong. |
847 @return Generated unique component of activity id |
1030 @return Generated unique component of activity id |
848 */ |
1031 */ |
849 IMPORT_C static TUint GetNextActivityCountL( const TNodeActivity& aActivitySig, const AMMNodeBase& aNode ); |
1032 static TUint GetNextActivityCountL( const TNodeActivity& aActivitySig, const AMMNodeBase& aNode ); |
|
1033 /** |
|
1034 For use by custom activity News to generate the unique part of the activity id. |
|
1035 @param aActivitySig Context information about how the activity is to be started |
|
1036 @param aNode The node to which this activity will belong. |
|
1037 @return Generated unique component of activity id |
|
1038 */ |
|
1039 IMPORT_C static TUint GetNextActivityCount( const TNodeActivity& aActivitySig, const AMMNodeBase& aNode ); |
850 |
1040 |
851 /** |
1041 /** |
852 Constructor for CNodeParallelActivityBase |
1042 Constructor for CNodeParallelActivityBase |
853 @param aActivitySig Context information about how the activity is to be started |
1043 @param aActivitySig Context information about how the activity is to be started |
854 @param aNode The node to which this activity will belong. |
1044 @param aNode The node to which this activity will belong. |