Manage shared memory. More...
#include "us_global.h"
Classes | |
class | Global |
Public Member Functions | |
US_Global () | |
Create or attach to shared memory. More... | |
~US_Global () | |
The destructor detaches from shared memory. More... | |
bool | isValid () |
An indicator that shared memory is valid. More... | |
QPoint | global_position (void) |
Get the point stored in shared memory. More... | |
void | set_global_position (const QPoint &) |
Sets the point in shared memory. More... | |
QString | passwd (void) |
Retrieves the unencrypted master password from shared memory. More... | |
void | setPasswd (const QString &) |
Sets the unencrypted master password into shared memory. More... | |
void | scheduleDelete (void) |
Only called by master program to schedule deleting of shared memory when killing child processes. More... | |
Private Member Functions | |
void | read_global (void) |
void | write_global (void) |
Private Attributes | |
Global | global |
bool | valid |
bool | deleteFlag |
QSharedMemory | sharedMemory |
Manage shared memory.
This class sets up shared memory and provides a convenient interface to read and write data in the shared memory area.
Definition at line 18 of file us_global.h.
US_Global::US_Global | ( | ) |
Create or attach to shared memory.
The constructor will attach to an existing shared memory area. If the area does not exist, it create it and then attach to it.
A shared memory area is identified by a unique key. In this case it is defined as:
"UltraScan" + QString( getuid() )
In this way, each user on a multi-user system will get a uniqe key.
Note that this has not been tested yet in Windows as Windows doesn't have getuid() equivalent. On th eother hand, it probably isn't necessary because Windows generally only has one person running on a client system at a time.
Right now there is only one value stored in shared memory: the location of the upper left corner of the last program that started. It is initialized to QPoint( 50, 50 ).
Definition at line 10 of file us_global.cpp.
US_Global::~US_Global | ( | ) |
The destructor detaches from shared memory.
The destructor detaches from shared memory. If it is the last program attached, the shared memory area is destroyed.
Definition at line 49 of file us_global.cpp.
QPoint US_Global::global_position | ( | void | ) |
Get the point stored in shared memory.
This function returns the point of the upper left corner that the window should use.
Definition at line 62 of file us_global.cpp.
|
inline |
An indicator that shared memory is valid.
A function to return the state of the shared memory segment. If there was an error creating or attaching to the shared memory, it will return false.
Definition at line 57 of file us_global.h.
QString US_Global::passwd | ( | void | ) |
Retrieves the unencrypted master password from shared memory.
This function returns a character string as a QString.
Definition at line 75 of file us_global.cpp.
|
private |
Definition at line 83 of file us_global.cpp.
|
inline |
Only called by master program to schedule deleting of shared memory when killing child processes.
Definition at line 90 of file us_global.h.
void US_Global::set_global_position | ( | const QPoint & | p | ) |
Sets the point in shared memory.
p | The point to save |
This function sets the point that the next program should use for its upper left corner. The calling program should increnment this point after it retrives the current point and decrement it when terminating.
Definition at line 55 of file us_global.cpp.
void US_Global::setPasswd | ( | const QString & | pw | ) |
Sets the unencrypted master password into shared memory.
pw | The unencrypted master password |
Definition at line 68 of file us_global.cpp.
|
private |
Definition at line 91 of file us_global.cpp.
|
private |
Definition at line 115 of file us_global.h.
|
private |
Definition at line 113 of file us_global.h.
|
private |
Definition at line 116 of file us_global.h.
|
private |
Definition at line 114 of file us_global.h.