keepalive/flextimer/test/testflextimer/flextimerservermonitor/inc/flextimerservermonitorserver.h
changeset 32 5c4486441ae6
equal deleted inserted replaced
31:c16e04725da3 32:5c4486441ae6
       
     1 /*
       
     2  * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
       
     3  * All rights reserved.
       
     4  * This component and the accompanying materials are made available
       
     5  * under the terms of "Eclipse Public License v1.0"
       
     6  * which accompanies this distribution, and is available
       
     7  * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8  *
       
     9  * Initial Contributors:
       
    10  * Nokia Corporation - initial contribution.
       
    11  *
       
    12  * Contributors:
       
    13  *
       
    14  * Description:
       
    15  *      Server implementation for FlexTimerServerMonitor.
       
    16  */
       
    17 /*
       
    18  * %version: 1 %
       
    19  */
       
    20 // Protection against nested includes
       
    21 #ifndef FLEXTIMERSERVERMONITORSERVER_H
       
    22 #define FLEXTIMERSERVERMONITORSERVER_H
       
    23 
       
    24 // System includes
       
    25 #include <e32base.h>
       
    26 #include <rflextimer.h>
       
    27 
       
    28 // Class declaration
       
    29 /**
       
    30  * A server for detecting, has FlexTimerServer crashed during the
       
    31  * monitoring period.
       
    32  */
       
    33 class CFlexTimerServerMonitorServer : public CServer2
       
    34     {
       
    35     
       
    36 public:
       
    37     /**
       
    38      * Two phased constructor 
       
    39      * 
       
    40      * @param aPriority Active object priority for the server 
       
    41      * @return Pointer to created server object
       
    42      */
       
    43     IMPORT_C static CFlexTimerServerMonitorServer* NewL( 
       
    44         CActive::TPriority aPriority );
       
    45 
       
    46     /**
       
    47      * Destructor 
       
    48      */
       
    49     virtual ~CFlexTimerServerMonitorServer();
       
    50 
       
    51 public:
       
    52 
       
    53     /**
       
    54      * From CServer2
       
    55      * Function for creating a new session to this server. 
       
    56      *
       
    57      * @param aVersion Version identifier from client
       
    58      * @param aMessage Reference to creation message sent by client
       
    59      * @return Pointer to created session object
       
    60      */
       
    61     CSession2* NewSessionL( const TVersion& aVersion,
       
    62                             const RMessage2& aMessage ) const;
       
    63 
       
    64     /**
       
    65      * Function for creating server thread resources. Creates the server
       
    66      * object and active scheduler. Loops in the active scheduler to serve
       
    67      * client requests until explicitly shutdown. Function leaves if the
       
    68      * creation of needed resources fails.
       
    69      */
       
    70     static void StartServerL();
       
    71 
       
    72     /**
       
    73      * Start monitoring FlexTimer server crashing.
       
    74      * 
       
    75      * @return KErrNone when succeeded, KErrAlreadyExists if monitoring was
       
    76      * already started, or any other system level error code.
       
    77      */
       
    78     TInt StartMonitoring();
       
    79     
       
    80     /**
       
    81      * Stop monitoring FlexTimer server crashing.
       
    82      * 
       
    83      * @return KErrNone when succeeded, KErrNotFound if monitoring is not
       
    84      * started.
       
    85      */
       
    86     TInt StopMonitoring();
       
    87     
       
    88     /**
       
    89      * Get status of monitoring the server. I.e. has the server crashed or 
       
    90      * not.
       
    91      *
       
    92      * @param aHasServerCrashed Return ETrue if server has crashed while
       
    93      * monitoring, otherwise EFalse.
       
    94      * @return KErrNone when succeeded, KErrNotFound if monitoring is not
       
    95      * started.
       
    96      */
       
    97     TInt GetStatus( TBool& aHasServerCrashed );
       
    98     
       
    99 private:
       
   100 
       
   101     /**
       
   102      * Constructor
       
   103      * 
       
   104      * @param aPriority Active object priority 
       
   105      */
       
   106     CFlexTimerServerMonitorServer( CActive::TPriority aPriority );
       
   107 
       
   108 private: // Data
       
   109 
       
   110     /**
       
   111      * Handle to FlexTimer server.
       
   112      * This parameter needs to be in server due it is manipulated by
       
   113      * multible sessions.
       
   114      */
       
   115     RFlexTimer iFlexTimer;
       
   116     
       
   117     /**
       
   118      * State of monitoring. ETrue if monitoring has started, EFalse if not.
       
   119      * This state is introduced for preventing starting/stopping the
       
   120      * monitoring more than once in a row.
       
   121      */
       
   122     TBool iIsMonitoringOn;
       
   123     };
       
   124 
       
   125 #endif /* FLEXTIMERSERVERMONITORSERVER_H */