Subversion Repositories WindowManager

Compare Revisions

Ignore whitespace Rev 3 → Rev 4

/trunk/wimp/task.cc
New file
0,0 → 1,42
// This file is part of the free Window Manager module.
// Copyright © 2007 Graham Shaw.
// Redistribution and modification are permitted within the terms of the
// GNU General Public License (version 2 or any later version).
 
#include <cstring>
#include <new>
 
#include "oslib/thread.h"
 
#include "task.h"
 
namespace {
 
inline int current_thread()
{
int handle=0;
xthread_self(&handle);
return handle;
}
 
}; /* anonymous namespace */
 
task::task(const char* name,wimp_version_no wimp_version):
_handle(current_thread()),
_name(0),
_wimp_version(wimp_version)
{
const char* name_end=name;
while (*name_end>=' ') ++name_end;
_name=new(std::nothrow) char[1+name_end-name];
if (_name)
{
memcpy(_name,name,name_end-name);
_name[name_end-name]=0;
}
}
 
task::~task()
{
delete[] _name;
}
/trunk/wimp/task.h
New file
0,0 → 1,51
// This file is part of the free Window Manager module.
// Copyright © 2007 Graham Shaw.
// Redistribution and modification are permitted within the terms of the
// GNU General Public License (version 2 or any later version).
 
#ifndef WINDOWMANAGER_TASK
#define WINDOWMANAGER_TASK
 
#include "oslib/wimp.h"
 
/** A class to represent a Wimp task. */
class task
{
private:
/** The task handle. */
int _handle;
 
/** The name of this task. */
char* _name;
 
/** The Wimp API version to be used for this task. */
wimp_version_no _wimp_version;
public:
/** Construct task.
* @param wimp_version the Wimp API version to be used for this task
*/
task(const char* name,wimp_version_no wimp_version);
 
/** Destroy task. */
~task();
 
/** Get task handle.
* @return the task handle for this task
*/
int handle() const
{ return _handle; }
 
/** Get task name.
* @return the name of this task
*/
const char* name() const
{ return _name; }
 
/** Get Wimp API version.
* @return wimp_version the Wimp API version to be used for this task
*/
wimp_version_no wimp_version()
{ return _wimp_version; }
};
 
#endif