wxWidgets: wxPowerResourceBlocker Class Reference

| Version: 3.1.5

Loading...
Searching...
No Matches
Public Member Functions | List of all members
wxPowerResourceBlocker Class Reference
Class List by Category » Miscellaneous

`#include </cygdrive/c/Users/Hamis/Cygwin-packaging/wxWidgets3.1/wxWidgets3.1-3.1.5-3.x86_64/src/wxWidgets-3.1.5/interface/wx/power.h>`

## Detailed Description

Helper RAII class ensuring that power resources are released.

A wxPowerResourceBlocker object acquires a power resource in the constructor and releases it in the destructor making it impossible to forget to release the power resource (which would prevent suspending or screen power off until the application ends).

Example:

void MyWindow::DoSomething()
{
wxPowerResourceBlocker
blocker(wxPOWER_RESOURCE_SYSTEM, "Downloading something important");
if ( !blocker.IsInEffect() )
{
// If the resource could not be acquired, tell the user that he has
// to keep the system alive
wxLogMessage("Warning: system may suspend while downloading.");
}
// Run an important download and the system will not suspend while downloading
for ( int i = 0; i < download.size(); ++i )
download.readByte();
// wxPOWER_RESOURCE_SYSTEM automatically released here.
}
wxPowerResourceBlocker::wxPowerResourceBlocker
wxPowerResourceBlocker(wxPowerResourceKind kind, const wxString &reason=wxString())
Acquires the power resource.
wxLogMessage
void wxLogMessage(const char *formatString,...)
For all normal, informational messages.
wxPOWER_RESOURCE_SYSTEM
@ wxPOWER_RESOURCE_SYSTEM
Use to prevent automatic system suspend.
Definition power.h:35

Since
  3.1.0

  ##

Library: wxBase

<>< =''>:</>&;&;< =''>\ </></>

See also
  wxPowerResource

## Public Member Functions
| wxPowerResourceBlocker (wxPowerResourceKind kind, const wxString &reason=wxString())
| Acquires the power resource.
bool | IsInEffect () const
| Returns whether the power resource could be acquired.
| ~wxPowerResourceBlocker ()
| Releases the power resource.

## Constructor & Destructor Documentation

## ◆ wxPowerResourceBlocker()

wxPowerResourceBlocker::wxPowerResourceBlocker | ( | wxPowerResourceKind | kind,
|  | const wxString & | reason = wxString() )
| explicit

Acquires the power resource.

Uses the same parameters as wxPowerResource::Acquire().

## ◆ ~wxPowerResourceBlocker()

wxPowerResourceBlocker::~wxPowerResourceBlocker | ( |  | ) |

Releases the power resource.

See also
  wxPowerResource::Release()

## Member Function Documentation

## ◆ IsInEffect()

bool wxPowerResourceBlocker::IsInEffect | ( |  | ) | const

Returns whether the power resource could be acquired.

This can be used to inform the user that the application will not prevent automatic suspending.

See also
  wxPowerResource::Acquire()