commsfwsupport/commselements/testing/dummystatelibrary/inc/dummynode.h
changeset 0 dfb7c4ff071f
equal deleted inserted replaced
-1:000000000000 0:dfb7c4ff071f
       
     1 // Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // CORECPR.h
       
    15 // Core CPR
       
    16 // 
       
    17 //
       
    18 
       
    19 /**
       
    20  @file
       
    21  @internalComponent
       
    22 */
       
    23 
       
    24 #ifndef DUMMYNODE_H
       
    25 #define DUMMYNODE_H
       
    26 
       
    27 #include <elements/mm_activities.h>
       
    28 #include <elements/mm_node.h>
       
    29 #include <elements/factory.h>
       
    30 
       
    31 
       
    32 #ifdef _DEBUG
       
    33 // Panic category for "absolutely impossible!" vanilla ASSERT()-type panics from this module
       
    34 // (if it could happen through user error then you should give it an explicit, documented, category + code)
       
    35 _LIT(KSpecAssert_ElemTestingdmynd, "ElemTestingdmynd");
       
    36 #endif
       
    37 
       
    38 namespace Dummy
       
    39 {
       
    40 
       
    41 enum TDummyNodeActivityId
       
    42 	{
       
    43 	EActivityStart                  = MeshMachine::KActivityNull + 1,
       
    44 	EActivityStop                   = 2,
       
    45 	EActivityDestroy                = 3,
       
    46 	EActivityClientJoin             = 4,
       
    47 	EActivityClientLeave            = 5,
       
    48 	EActivityError                  = 6,//if found in node activity map is ran by the MM
       
    49 	};
       
    50 
       
    51 class TDummyClientType : public Messages::TClientType
       
    52 	{
       
    53 public:
       
    54     enum TType
       
    55         {
       
    56         //-=============================================
       
    57         //
       
    58         // 1. Types 32bits (a client can only have one type)
       
    59         //
       
    60         // TClientType = BIT0..BIT7
       
    61         //-=============================================
       
    62         EClient       = 0x00000100,
       
    63         EServProvider = 0x00000200
       
    64 		};
       
    65 
       
    66 	enum TFlags
       
    67 		{
       
    68         //-=============================================
       
    69         //
       
    70         // 2. Flags 32bits (a client can have many flags)
       
    71         //
       
    72         // TClientType = BIT0..BIT7
       
    73         //-=============================================
       
    74         EActive       = 0x00000100, //Client that has started us
       
    75         EStarting     = 0x00000200, //Service Provider that is starting
       
    76 		EStopping     = 0x00000400, //Service Provider that is stopping
       
    77 		EStarted      = 0x00000800  //Service Provider that is started (stopped if not set)
       
    78         };
       
    79 
       
    80 public:
       
    81 	TDummyClientType()
       
    82 	:	Messages::TClientType(EUnknown)
       
    83 		{
       
    84 		}
       
    85 
       
    86 	TDummyClientType(TUint32 aClientType, TUint32 aClientFlags)
       
    87 	:	Messages::TClientType(aClientType, aClientFlags)
       
    88 		{
       
    89 		}
       
    90 	};
       
    91 
       
    92 class CTestNodeBase : public CBase,
       
    93                       public Factories::AFactoryObject,
       
    94                       public MeshMachine::AMMNodeIdBase
       
    95     {
       
    96     friend class CTestFactoryBase;
       
    97 
       
    98 public:
       
    99 	IMPORT_C virtual ~CTestNodeBase();
       
   100 	virtual TUid ServiceProviderUid() const = 0;
       
   101 
       
   102 	void CommenceJoin()
       
   103 		{
       
   104 		--iOutstandingJoinCount;
       
   105 		__ASSERT_DEBUG(iOutstandingJoinCount>=0, User::Panic(KSpecAssert_ElemTestingdmynd, 1)); //It should never get below 0
       
   106 		}
       
   107 
       
   108 	TBool IsJoinOutstanding()
       
   109 		{
       
   110 		return iOutstandingJoinCount > 0;
       
   111 		}
       
   112 
       
   113 protected:
       
   114     IMPORT_C CTestNodeBase(Factories::CFactoryBase& aFactory, const MeshMachine::TNodeActivityMap& aActivityMap);
       
   115     IMPORT_C void Received(MeshMachine::TNodeContextBase& aContext);
       
   116     IMPORT_C void ReceivedL(const Messages::TRuntimeCtxId& aSender, const Messages::TNodeId& aRecipient, Messages::TSignatureBase& aMessage);
       
   117 
       
   118 private:
       
   119 	TInt iOutstandingJoinCount; //In our demo the Factory increments this, node decrements
       
   120     };
       
   121 
       
   122 } //Dummy
       
   123 
       
   124 #endif
       
   125 //DUMMYNODE_H
       
   126