CCAux  2.20.0.0
CCAux API reference
PowerMgr.h
Go to the documentation of this file.
1 
2 /*
3  * Copyright (C) 2023 CrossControl AB
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; with
8  * version 2.1 of the License.
9  */
10 /*
11  * File description:
12  * Access functions for managing application shutdown/cleanup
13  * when suspend or shutdown events occur. An application can use this framework
14  * to delay a suspend/shutdown until it is ready with any tasks it needs to do.
15  * It is also possible to use existing OS functions to achieve the same result.
16  *
17  * Note that applications should not use these functions to delay a suspend/shutdown
18  * request for a long time (more than 20-30s depending on platform). The computer will
19  * eventually be shut down forcibly if the application does not respond.
20  *
21  * It is not recommended for multiple applications to access the PowerMgr
22  * functionality simultaneously, although it is supported on some platforms.
23  *
24  * Note that a shutdown initiated by the OS will not be caught by this framework.
25  *
26  * Example Usage:
27  * @include powermgr_example.cpp
28  *
29  ************************************************/
30 
31 #ifndef CC_POWERMGR_H_
32 #define CC_POWERMGR_H_
33 
34 #include "CCAuxErrors.h"
35 #include "CCAuxTypes.h"
36 #include "CCPlatform.h"
37 
38 #ifdef __cplusplus
39 namespace CrossControl
40 {
41 #endif
42 
46 typedef enum
47 {
53  Normal = 0,
54 
59 
66  BatterySuspend = 2
68 
69 typedef enum
70 {
82  ShutdownPending = 2
84 
85 typedef void *POWERMGRHANDLE;
86 
106 EXTERN_C
107 CCAUXDLL_API
109 CCAUXDLL_CALLING_CONV
111 
122 EXTERN_C
123 CCAUXDLL_API
124 void CCAUXDLL_CALLING_CONV PowerMgr_release(POWERMGRHANDLE);
125 
138 EXTERN_C
139 CCAUXDLL_API
141 
154 EXTERN_C
155 CCAUXDLL_API
157 
171 EXTERN_C
172 CCAUXDLL_API
174 
187 EXTERN_C
188 CCAUXDLL_API
190 
204 EXTERN_C
205 CCAUXDLL_API
206 eErr CCAUXDLL_CALLING_CONV PowerMgr_hasResumed(POWERMGRHANDLE, bool *resumed);
207 
209 #ifdef __cplusplus
210 }
211 #endif
212 
213 #endif /* CC_POWERMGR_H_ */
EXTERN_C CCAUXDLL_API POWERMGRHANDLE CCAUXDLL_CALLING_CONV GetPowerMgr(void)
EXTERN_C CCAUXDLL_API eErr CCAUXDLL_CALLING_CONV PowerMgr_hasResumed(POWERMGRHANDLE, bool *resumed)
EXTERN_C CCAUXDLL_API eErr CCAUXDLL_CALLING_CONV PowerMgr_setAppReadyForSuspendOrShutdown(POWERMGRHANDLE)
EXTERN_C CCAUXDLL_API void CCAUXDLL_CALLING_CONV PowerMgr_release(POWERMGRHANDLE)
EXTERN_C CCAUXDLL_API eErr CCAUXDLL_CALLING_CONV PowerMgr_getConfiguration(POWERMGRHANDLE, PowerMgrConf *conf)
EXTERN_C CCAUXDLL_API eErr CCAUXDLL_CALLING_CONV PowerMgr_getPowerMgrStatus(POWERMGRHANDLE, PowerMgrStatus *status)
EXTERN_C CCAUXDLL_API eErr CCAUXDLL_CALLING_CONV PowerMgr_registerControlledSuspendOrShutDown(POWERMGRHANDLE, PowerMgrConf conf)
Definition: About.h:30
PowerMgrStatus
Definition: PowerMgr.h:70
@ SuspendPending
Definition: PowerMgr.h:78
@ NoRequestsPending
Definition: PowerMgr.h:74
@ ShutdownPending
Definition: PowerMgr.h:82
void * POWERMGRHANDLE
Definition: PowerMgr.h:85
PowerMgrConf
Definition: PowerMgr.h:47
@ Normal
Definition: PowerMgr.h:53
@ BatterySuspend
Definition: PowerMgr.h:66
@ ApplicationControlled
Definition: PowerMgr.h:58
eErr
Definition: CCAuxTypes.h:162