fixing indenting style issues

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20314 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Jérôme Duval
2007-03-03 15:26:57 +00:00
parent 5cb9bf4bbb
commit 96303159b3
16 changed files with 548 additions and 548 deletions
+3 -3
View File
@@ -34,10 +34,10 @@
#include "ExpanderWindow.h"
class ExpanderApp : public BApplication {
public:
public:
ExpanderApp();
public:
public:
virtual void AboutRequested();
virtual void ArgvReceived(int32 argc, char **argv);
virtual void ReadyToRun();
@@ -45,7 +45,7 @@ public:
ExpanderSettings fSettings;
void UpdateSettingsFrom(BMessage *message);
private:
private:
ExpanderWindow *fWindow;
};
+18 -18
View File
@@ -29,7 +29,7 @@ ExpanderPreferences::ExpanderPreferences(BMessage *settings)
B_WILL_DRAW | B_FRAME_EVENTS, B_PLAIN_BORDER);
AddChild(background);
rect.OffsetBy(11,9);
rect.OffsetBy(11, 9);
rect.bottom -= 64;
rect.right -= 22;
BBox *box = new BBox(rect, "background", B_FOLLOW_NONE,
@@ -37,15 +37,15 @@ ExpanderPreferences::ExpanderPreferences(BMessage *settings)
box->SetLabel("Expander Preferences");
background->AddChild(box);
float maxWidth=box->Bounds().right;
float maxWidth = box->Bounds().right;
BRect frameRect = box->Bounds();
frameRect.OffsetBy(15,23);
frameRect.OffsetBy(15, 23);
frameRect.right = frameRect.left + 200;
frameRect.bottom = frameRect.top + 20;
BRect textRect(frameRect);
textRect.OffsetTo(B_ORIGIN);
textRect.InsetBy(1,1);
textRect.InsetBy(1, 1);
BStringView *stringView = new BStringView(frameRect, "expansion", "Expansion:",
B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW);
stringView->ResizeToPreferred();
@@ -100,7 +100,7 @@ ExpanderPreferences::ExpanderPreferences(BMessage *settings)
frameRect = fSameDest->Frame();
frameRect.top = frameRect.bottom + 1;
fDestUse = new BRadioButton(frameRect, "destUse", "Use:",new BMessage(MSG_DESTUSE));
fDestUse = new BRadioButton(frameRect, "destUse", "Use:", new BMessage(MSG_DESTUSE));
fDestUse->ResizeToPreferred();
if (fDestUse->Frame().right > maxWidth)
maxWidth = fDestUse->Frame().right;
@@ -116,7 +116,7 @@ ExpanderPreferences::ExpanderPreferences(BMessage *settings)
fDestText->ResizeToPreferred();
fDestText->SetDivider(0);
fDestText->TextView()->MakeEditable(false);
fDestText->ResizeTo(158,fDestText->Frame().Height());
fDestText->ResizeTo(158, fDestText->Frame().Height());
fDestText->SetEnabled(false);
@@ -129,13 +129,13 @@ ExpanderPreferences::ExpanderPreferences(BMessage *settings)
box->AddChild(fSelect);
fSelect->SetEnabled(false);
fDestText->MoveBy(0,(fSelect->Frame().Height() - fDestText->Frame().Height())/2.0);
fDestText->ResizeTo(158,fDestText->Frame().Height());
fDestText->MoveBy(0, (fSelect->Frame().Height() - fDestText->Frame().Height()) / 2.0);
fDestText->ResizeTo(158, fDestText->Frame().Height());
frameRect = stringView->Frame();
frameRect.top = fDestUse->Frame().bottom + 10;
stringView = new BStringView(frameRect, "other", "Other:",B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW);
stringView = new BStringView(frameRect, "other", "Other:", B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW);
stringView->ResizeToPreferred();
if (stringView->Frame().right > maxWidth)
maxWidth = stringView->Frame().right;
@@ -158,28 +158,28 @@ ExpanderPreferences::ExpanderPreferences(BMessage *settings)
maxWidth = fAutoShow->Frame().right;
box->AddChild(fAutoShow);
box->ResizeTo(maxWidth + 15,fAutoShow->Frame().bottom + 10);
box->ResizeTo(maxWidth + 15, fAutoShow->Frame().bottom + 10);
rect = BRect(Bounds().right-89, Bounds().bottom-40, Bounds().right-14, Bounds().bottom-16);
rect = BRect(Bounds().right - 89, Bounds().bottom - 40, Bounds().right - 14, Bounds().bottom - 16);
rect = Bounds();
BButton *button = new BButton(rect, "OKButton", "OK",new BMessage(MSG_OK));
BButton *button = new BButton(rect, "OKButton", "OK", new BMessage(MSG_OK));
button->MakeDefault(true);
button->ResizeToPreferred();
button->MoveTo(box->Frame().right - button->Frame().Width(),box->Frame().bottom + 10 );
button->MoveTo(box->Frame().right - button->Frame().Width(), box->Frame().bottom + 10);
background->AddChild(button);
rect = button->Frame();
BButton *cancel = new BButton(rect, "CancelButton", "Cancel", new BMessage(MSG_CANCEL));
cancel->ResizeToPreferred();
cancel->MoveBy(-cancel->Frame().Width() - 10, (button->Frame().Height() - cancel->Frame().Height()) /2.0);
cancel->MoveBy(-cancel->Frame().Width() - 10, (button->Frame().Height() - cancel->Frame().Height()) / 2.0);
background->AddChild(cancel);
ResizeTo(box->Frame().right + 11 ,button->Frame().bottom + 11);
ResizeTo(box->Frame().right + 11 , button->Frame().bottom + 11);
BScreen screen(this);
MoveBy((screen.Frame().Width()-Bounds().Width())/2,
(screen.Frame().Height()-Bounds().Height())/2);
MoveBy((screen.Frame().Width() - Bounds().Width()) / 2,
(screen.Frame().Height() - Bounds().Height()) / 2);
bool automatically_expand_files;
bool close_when_done;
@@ -279,7 +279,7 @@ ExpanderPreferences::MessageReceived(BMessage *msg)
fSettings->ReplaceBool("automatically_expand_files", fAutoExpand->Value() == B_CONTROL_ON);
fSettings->ReplaceBool("close_when_done", fCloseWindow->Value() == B_CONTROL_ON);
fSettings->ReplaceInt8("destination_folder", (fSameDest->Value() == B_CONTROL_ON) ? 0x63
: ( (fLeaveDest->Value() == B_CONTROL_ON) ? 0x66 : 0x65) );
: ((fLeaveDest->Value() == B_CONTROL_ON) ? 0x66 : 0x65));
fSettings->ReplaceRef("destination_folder_use", &fRef);
fSettings->ReplaceBool("open_destination_folder", fOpenDest->Value() == B_CONTROL_ON);
fSettings->ReplaceBool("show_contents_listing", fAutoShow->Value() == B_CONTROL_ON);
+2 -2
View File
@@ -39,12 +39,12 @@
#include <RadioButton.h>
class ExpanderPreferences : public BWindow {
public:
public:
ExpanderPreferences(BMessage *settings);
virtual ~ExpanderPreferences();
virtual void MessageReceived(BMessage *msg);
private:
private:
BMessage *fSettings;
BCheckBox *fAutoExpand, *fCloseWindow, *fAutoShow, *fOpenDest;
BRadioButton *fDestUse, *fSameDest, *fLeaveDest;
+4 -4
View File
@@ -58,20 +58,20 @@ ExpanderRules::ExpanderRules()
char buffer[1024];
BString strings[4];
while (fgets(buffer, 1024-1, f)!=NULL) {
while (fgets(buffer, 1024 - 1, f) != NULL) {
int32 i = 0, j = 0;
int32 firstQuote = -1;
while (buffer[i] != '#' && buffer[i] != '\n' && j < 4) {
if ((j == 0 || j > 1) && buffer[i] == '"') {
if (firstQuote >= 0) {
strings[j++].SetTo(&buffer[firstQuote+1], i-firstQuote-1);
strings[j++].SetTo(&buffer[firstQuote+1], i - firstQuote - 1);
firstQuote = -1;
} else
firstQuote = i;
} else if (j == 1 && (buffer[i] == ' ' || buffer[i] == '\t')) {
if (firstQuote >= 0) {
if (firstQuote + 1 != i) {
strings[j++].SetTo(&buffer[firstQuote+1], i-firstQuote-1);
strings[j++].SetTo(&buffer[firstQuote+1], i - firstQuote - 1);
firstQuote = -1;
} else
firstQuote = i;
@@ -122,7 +122,7 @@ ExpanderRules::MatchingRule(BString &fileName, const char *filetype)
{
int32 count = fList.CountItems();
int32 length = fileName.Length();
for (int32 i=0; i<count; i++) {
for (int32 i = 0; i < count; i++) {
ExpanderRule *rule = (ExpanderRule *)fList.ItemAt(i);
if ((rule->MimeType().IsValid() && rule->MimeType() == filetype)
|| (fileName.FindLast(rule->FilenameExtension()) == (length - rule->FilenameExtension().Length())))
+5 -5
View File
@@ -91,7 +91,7 @@ ExpanderSettings::ExpanderSettings()
&& (file.Read(&ref.device, sizeof(ref.device)) == sizeof(ref.device))
&& (file.Read(&ref.directory, sizeof(ref.directory)) == sizeof(ref.directory))
&& (file.Read(&name_size, sizeof(name_size)) == sizeof(name_size))
&& ((name_size <= 0) || (ref.name = (char*)malloc(name_size+1)))
&& ((name_size <= 0) || (ref.name = (char*)malloc(name_size + 1)))
&& (file.Read(ref.name, name_size) == name_size)
&& (file.Read(&open_destination_folder, sizeof(open_destination_folder)) == sizeof(open_destination_folder))
&& (file.Read(&show_contents_listing, sizeof(show_contents_listing)) == sizeof(show_contents_listing))
@@ -105,12 +105,12 @@ ExpanderSettings::ExpanderSettings()
fMessage.ReplaceBool("automatically_expand_files", automatically_expand_files);
fMessage.ReplaceBool("close_when_done", close_when_done);
if(destination_folder == 0x66 || destination_folder == 0x63 || destination_folder == 0x65)
if (destination_folder == 0x66 || destination_folder == 0x63 || destination_folder == 0x65)
fMessage.ReplaceInt8("destination_folder", destination_folder);
if (name_size > 0)
ref.name[name_size] = '\0';
BEntry entry(&ref);
if(entry.Exists())
if (entry.Exists())
fMessage.ReplaceRef("destination_folder_use", &ref);
fMessage.ReplaceBool("open_destination_folder", open_destination_folder);
fMessage.ReplaceBool("show_contents_listing", show_contents_listing);
@@ -143,7 +143,7 @@ ExpanderSettings::~ExpanderSettings()
&& (fMessage.FindInt8("destination_folder", &destination_folder) == B_OK)
&& (fMessage.FindRef("destination_folder_use", &ref) == B_OK)
&& (fMessage.FindBool("open_destination_folder", &open_destination_folder) == B_OK)
&& (fMessage.FindBool("show_contents_listing", &show_contents_listing) == B_OK) ) {
&& (fMessage.FindBool("show_contents_listing", &show_contents_listing) == B_OK)) {
file.Write(&unknown, sizeof(unknown));
file.Write(&automatically_expand_files, sizeof(automatically_expand_files));
@@ -154,7 +154,7 @@ ExpanderSettings::~ExpanderSettings()
file.Write(&ref.device, sizeof(ref.device));
file.Write(&ref.directory, sizeof(ref.directory));
int32 name_size = 0;
if(ref.name)
if (ref.name)
name_size = strlen(ref.name);
file.Write(&name_size, sizeof(name_size));
file.Write(ref.name, name_size);
+18 -18
View File
@@ -13,8 +13,8 @@
const char * ExpanderThreadName = "ExpanderThread";
ExpanderThread::ExpanderThread (BMessage * refs_message, BMessenger * messenger)
: GenericThread(ExpanderThreadName, B_NORMAL_PRIORITY, refs_message),
ExpanderThread::ExpanderThread(BMessage * refs_message, BMessenger * messenger)
: GenericThread(ExpanderThreadName, B_NORMAL_PRIORITY, refs_message),
fWindowMessenger(messenger),
fThreadId(-1),
fStdIn(-1),
@@ -24,7 +24,7 @@ ExpanderThread::ExpanderThread (BMessage * refs_message, BMessenger * messenger)
fExpanderOutputString(),
fExpanderOutputBuffer(new char [4096])
{
SetDataStore(new BMessage (* refs_message)); // leak?
SetDataStore(new BMessage(* refs_message)); // leak?
// prevents bug with B_SIMPLE_DATA
// (drag&drop messages)
}
@@ -42,13 +42,13 @@ ExpanderThread::ThreadStartup()
entry_ref srcRef, destRef;
BString cmd;
if ((status = GetDataStore()->FindRef("srcRef", &srcRef))!=B_OK)
if ((status = GetDataStore()->FindRef("srcRef", &srcRef)) != B_OK)
return status;
if ((status = GetDataStore()->FindRef("destRef", &destRef))==B_OK) {
if ((status = GetDataStore()->FindRef("destRef", &destRef)) == B_OK) {
BPath path(&destRef);
chdir(path.Path());
}
if ((status = GetDataStore()->FindString("cmd", &cmd))!=B_OK)
if ((status = GetDataStore()->FindString("cmd", &cmd)) != B_OK)
return status;
BPath path(&srcRef);
@@ -81,21 +81,21 @@ ExpanderThread::ThreadStartup()
}
status_t
ExpanderThread::ExecuteUnit (void)
ExpanderThread::ExecuteUnit(void)
{
// read output from command
// send it to window
char *output_string = fgets(fExpanderOutputBuffer , 4096-1, fExpanderOutput);
char *output_string = fgets(fExpanderOutputBuffer , 4096 - 1, fExpanderOutput);
if (output_string == NULL)
return EOF;
BMessage message('outp');
message.AddString("output", output_string);
for (int32 i=0; i<5; i++) {
output_string = fgets(fExpanderOutputBuffer , 4096-1, fExpanderOutput);
if(!output_string)
for (int32 i = 0; i < 5; i++) {
output_string = fgets(fExpanderOutputBuffer , 4096 - 1, fExpanderOutput);
if (!output_string)
break;
message.AddString("output", output_string);
}
@@ -164,12 +164,12 @@ ExpanderThread::PipeCommand(int argc, const char **argv, int &in, int &out, int
int filedes[2];
/* Create new pipe FDs as stdin, stdout, stderr */
pipe(filedes); dup2(filedes[0],0); close(filedes[0]);
in=filedes[1]; // Write to in, appears on cmd's stdin
pipe(filedes); dup2(filedes[1],1); close(filedes[1]);
out=filedes[0]; // Read from out, taken from cmd's stdout
pipe(filedes); dup2(filedes[1],2); close(filedes[1]);
err=filedes[0]; // Read from err, taken from cmd's stderr
pipe(filedes); dup2(filedes[0], 0); close(filedes[0]);
in = filedes[1]; // Write to in, appears on cmd's stdin
pipe(filedes); dup2(filedes[1], 1); close(filedes[1]);
out = filedes[0]; // Read from out, taken from cmd's stdout
pipe(filedes); dup2(filedes[1], 2); close(filedes[1]);
err = filedes[0]; // Read from err, taken from cmd's stderr
// "load" command.
thread_id ret = load_image(argc, argv, envp);
@@ -222,7 +222,7 @@ status_t
ExpanderThread::InterruptExternalExpander()
{
thread_info thread_info;
status_t status = get_thread_info (fThreadId, &thread_info);
status_t status = get_thread_info(fThreadId, &thread_info);
if (status == B_OK) {
status = send_signal(-fThreadId, SIGINT);
+2 -2
View File
@@ -42,7 +42,7 @@ extern const char * ExpanderThreadName;
class ExpanderThread : public GenericThread
{
public:
public:
ExpanderThread(BMessage *refs_message, BMessenger *messenger);
~ExpanderThread();
@@ -51,7 +51,7 @@ public:
status_t InterruptExternalExpander();
status_t WaitOnExternalExpander();
private:
private:
virtual status_t ThreadStartup();
virtual status_t ExecuteUnit();
+7 -7
View File
@@ -234,7 +234,7 @@ ExpanderWindow::MessageReceived(BMessage *msg)
BAlert *alert = new BAlert("stopAlert", "Are you sure you want to stop expanding this\n"
"archive? The expanded items may not be complete.", "Stop", "Continue", NULL,
B_WIDTH_AS_USUAL, B_EVEN_SPACING, B_WARNING_ALERT);
if (alert->Go()==0) {
if (alert->Go() == 0) {
fExpandingThread->ResumeExternalExpander();
StopExpanding();
} else
@@ -319,8 +319,8 @@ ExpanderWindow::MessageReceived(BMessage *msg)
case 'outp':
if (!fExpandingStarted && fListingStarted) {
BString string;
int32 i=0;
while (msg->FindString("output", i++, &string)==B_OK)
int32 i = 0;
while (msg->FindString("output", i++, &string) == B_OK)
fListingText->Insert(string.String());
fListingText->ScrollToSelection();
}
@@ -364,7 +364,7 @@ ExpanderWindow::CanQuit()
BAlert *alert = new BAlert("stopAlert", "Are you sure you want to stop expanding this\n"
"archive? The expanded items may not be complete.", "Stop", "Continue", NULL,
B_WIDTH_AS_USUAL, B_EVEN_SPACING, B_WARNING_ALERT);
if (alert->Go()==0) {
if (alert->Go() == 0) {
fExpandingThread->ResumeExternalExpander();
StopExpanding();
} else {
@@ -409,12 +409,12 @@ ExpanderWindow::RefsReceived(BMessage *msg)
fSourceChanged = true;
fSourceRef = ref;
fSourceText->SetText(path.Path());
if (destination_folder==0x63) {
if (destination_folder == 0x63) {
BPath parent;
path.GetParent(&parent);
fDestText->SetText(parent.Path());
get_ref_for_path(parent.Path(), &fDestRef);
} else if (destination_folder==0x65) {
} else if (destination_folder == 0x65) {
fSettings.FindRef("destination_folder_use", &fDestRef);
BEntry dEntry(&fDestRef, true);
BPath dPath(&dEntry);
@@ -440,7 +440,7 @@ ExpanderWindow::RefsReceived(BMessage *msg)
AutoExpand();
} else
AutoListing();
} else if(node.IsDirectory()) {
} else if (node.IsDirectory()) {
fDestRef = ref;
fDestText->SetText(path.Path());
}
+62 -62
View File
@@ -5,11 +5,11 @@
GenericThread::GenericThread(const char * a_thread_name, int32 a_priority, BMessage * a_message)
:
m_thread_data_store (a_message),
m_thread_id (spawn_thread (private_thread_function, a_thread_name, a_priority, this)),
m_execute_unit (create_sem(1, "m_execute_unit")),
m_quit_requested (false),
m_thread_is_paused (false)
m_thread_data_store(a_message),
m_thread_id(spawn_thread(private_thread_function, a_thread_name, a_priority, this)),
m_execute_unit(create_sem(1, "m_execute_unit")),
m_quit_requested(false),
m_thread_is_paused(false)
{
if (m_thread_data_store == NULL)
m_thread_data_store = new BMessage();
@@ -23,26 +23,26 @@ GenericThread::~GenericThread()
}
status_t
GenericThread::ThreadFunction (void)
GenericThread::ThreadFunction(void)
{
status_t status = B_OK;
status = ThreadStartup(); // Subclass and override this function
if (status != B_OK)
{
ThreadStartupFailed (status);
ThreadStartupFailed(status);
return (status);
// is this the right thing to do?
}
while(1)
while (1)
{
if (HasQuitBeenRequested())
{
status = ThreadShutdown(); // Subclass and override this function
if (status != B_OK)
{
ThreadShutdownFailed (status);
ThreadShutdownFailed(status);
return (status);
// what do we do?
}
@@ -55,7 +55,7 @@ GenericThread::ThreadFunction (void)
status = ExecuteUnit(); // Subclass and override
if (status != B_OK)
ExecuteUnitFailed (status); // Subclass and override
ExecuteUnitFailed(status); // Subclass and override
EndUnit();
}
@@ -64,7 +64,7 @@ GenericThread::ThreadFunction (void)
}
status_t
GenericThread::ThreadStartup (void)
GenericThread::ThreadStartup(void)
{
// This function is virtual.
// Subclass and override this function.
@@ -74,7 +74,7 @@ GenericThread::ThreadStartup (void)
status_t
GenericThread::ExecuteUnit (void)
GenericThread::ExecuteUnit(void)
{
// This function is virtual.
@@ -86,7 +86,7 @@ GenericThread::ExecuteUnit (void)
}
status_t
GenericThread::ThreadShutdown (void)
GenericThread::ThreadShutdown(void)
{
// This function is virtual.
// Subclass and override this function.
@@ -95,7 +95,7 @@ GenericThread::ThreadShutdown (void)
}
void
GenericThread::ThreadStartupFailed (status_t a_status)
GenericThread::ThreadStartupFailed(status_t a_status)
{
// This function is virtual.
// Subclass and override this function.
@@ -104,7 +104,7 @@ GenericThread::ThreadStartupFailed (status_t a_status)
}
void
GenericThread::ExecuteUnitFailed (status_t a_status)
GenericThread::ExecuteUnitFailed(status_t a_status)
{
// This function is virtual.
// Subclass and override this function.
@@ -113,7 +113,7 @@ GenericThread::ExecuteUnitFailed (status_t a_status)
}
void
GenericThread::ThreadShutdownFailed (status_t a_status)
GenericThread::ThreadShutdownFailed(status_t a_status)
{
// This function is virtual.
// Subclass and override this function.
@@ -122,26 +122,26 @@ GenericThread::ThreadShutdownFailed (status_t a_status)
}
status_t
GenericThread::Start (void)
GenericThread::Start(void)
{
status_t status = B_OK;
if (IsPaused())
{
status = release_sem (m_execute_unit);
status = release_sem(m_execute_unit);
if (status != B_OK)
return status;
m_thread_is_paused = false;
}
status = resume_thread (m_thread_id);
status = resume_thread(m_thread_id);
return status;
}
int32
GenericThread::private_thread_function (void * a_simple_thread_ptr)
GenericThread::private_thread_function(void * a_simple_thread_ptr)
{
status_t status = B_OK;
@@ -151,19 +151,19 @@ GenericThread::private_thread_function (void * a_simple_thread_ptr)
}
BMessage *
GenericThread::GetDataStore (void)
GenericThread::GetDataStore(void)
{
return (m_thread_data_store);
}
void
GenericThread::SetDataStore (BMessage * a_message)
GenericThread::SetDataStore(BMessage * a_message)
{
m_thread_data_store = a_message;
}
status_t
GenericThread::Pause (bool a_do_block, bigtime_t a_timeout)
GenericThread::Pause(bool a_do_block, bigtime_t a_timeout)
{
status_t status = B_OK;
@@ -184,31 +184,31 @@ GenericThread::Pause (bool a_do_block, bigtime_t a_timeout)
}
void
GenericThread::Quit (void)
GenericThread::Quit(void)
{
m_quit_requested = true;
}
bool
GenericThread::HasQuitBeenRequested (void)
GenericThread::HasQuitBeenRequested(void)
{
return (m_quit_requested);
}
bool
GenericThread::IsPaused (void)
GenericThread::IsPaused(void)
{
return (m_thread_is_paused);
}
status_t
GenericThread::Suspend (void)
GenericThread::Suspend(void)
{
return (suspend_thread(m_thread_id));
}
status_t
GenericThread::Resume (void)
GenericThread::Resume(void)
{
release_sem(m_execute_unit); // to counteract Pause()
m_thread_is_paused = false;
@@ -217,61 +217,61 @@ GenericThread::Resume (void)
}
status_t
GenericThread::Kill (void)
GenericThread::Kill(void)
{
return (kill_thread(m_thread_id));
}
void
GenericThread::ExitWithReturnValue (status_t a_return_value)
GenericThread::ExitWithReturnValue(status_t a_return_value)
{
exit_thread(a_return_value);
}
status_t
GenericThread::SetExitCallback (void (*a_callback)(void*), void * a_data)
GenericThread::SetExitCallback(void(*a_callback)(void*), void * a_data)
{
return (on_exit_thread(a_callback, a_data));
}
status_t
GenericThread::WaitForThread (status_t * a_exit_value)
GenericThread::WaitForThread(status_t * a_exit_value)
{
return (wait_for_thread(m_thread_id, a_exit_value));
}
status_t
GenericThread::Rename (char * a_name)
GenericThread::Rename(char * a_name)
{
return (rename_thread(m_thread_id, a_name));
}
status_t
GenericThread::SendData (int32 a_code, void * a_buffer, size_t a_buffer_size)
GenericThread::SendData(int32 a_code, void * a_buffer, size_t a_buffer_size)
{
return (send_data(m_thread_id, a_code, a_buffer, a_buffer_size));
}
int32
GenericThread::ReceiveData (thread_id * a_sender, void * a_buffer, size_t a_buffer_size)
GenericThread::ReceiveData(thread_id * a_sender, void * a_buffer, size_t a_buffer_size)
{
return (receive_data(a_sender, a_buffer, a_buffer_size));
}
bool
GenericThread::HasData (void)
GenericThread::HasData(void)
{
return (has_data(m_thread_id));
}
status_t
GenericThread::SetPriority (int32 a_new_priority)
GenericThread::SetPriority(int32 a_new_priority)
{
return (set_thread_priority(m_thread_id, a_new_priority));
}
void
GenericThread::Snooze (bigtime_t a_microseconds)
GenericThread::Snooze(bigtime_t a_microseconds)
{
Suspend();
snooze(a_microseconds);
@@ -279,7 +279,7 @@ GenericThread::Snooze (bigtime_t a_microseconds)
}
void
GenericThread::SnoozeUntil (bigtime_t a_microseconds, int a_timebase)
GenericThread::SnoozeUntil(bigtime_t a_microseconds, int a_timebase)
{
Suspend();
snooze_until(a_microseconds, a_timebase);
@@ -287,99 +287,99 @@ GenericThread::SnoozeUntil (bigtime_t a_microseconds, int a_timebase)
}
status_t
GenericThread::GetInfo (thread_info * a_thread_info)
GenericThread::GetInfo(thread_info * a_thread_info)
{
return (get_thread_info(m_thread_id, a_thread_info));
}
thread_id
GenericThread::GetThread (void)
GenericThread::GetThread(void)
{
thread_info t_thread_info;
GetInfo (& t_thread_info);
GetInfo(& t_thread_info);
return (t_thread_info.thread);
}
team_id
GenericThread::GetTeam (void)
GenericThread::GetTeam(void)
{
thread_info t_thread_info;
GetInfo (& t_thread_info);
GetInfo(& t_thread_info);
return (t_thread_info.team);
}
char *
GenericThread::GetName (void)
GenericThread::GetName(void)
{
thread_info t_thread_info;
GetInfo (& t_thread_info);
GetInfo(& t_thread_info);
return (t_thread_info.name);
}
thread_state
GenericThread::GetState (void)
GenericThread::GetState(void)
{
thread_info t_thread_info;
GetInfo (& t_thread_info);
GetInfo(& t_thread_info);
return (t_thread_info.state);
}
sem_id
GenericThread::GetSemaphore (void)
GenericThread::GetSemaphore(void)
{
thread_info t_thread_info;
GetInfo (& t_thread_info);
GetInfo(& t_thread_info);
return (t_thread_info.sem);
}
int32
GenericThread::GetPriority (void)
GenericThread::GetPriority(void)
{
thread_info t_thread_info;
GetInfo (& t_thread_info);
GetInfo(& t_thread_info);
return (t_thread_info.priority);
}
bigtime_t
GenericThread::GetUserTime (void)
GenericThread::GetUserTime(void)
{
thread_info t_thread_info;
GetInfo (& t_thread_info);
GetInfo(& t_thread_info);
return (t_thread_info.user_time);
}
bigtime_t
GenericThread::GetKernelTime (void)
GenericThread::GetKernelTime(void)
{
thread_info t_thread_info;
GetInfo (& t_thread_info);
GetInfo(& t_thread_info);
return (t_thread_info.kernel_time);
}
void *
GenericThread::GetStackBase (void)
GenericThread::GetStackBase(void)
{
thread_info t_thread_info;
GetInfo (& t_thread_info);
GetInfo(& t_thread_info);
return (t_thread_info.stack_base);
}
void *
GenericThread::GetStackEnd (void)
GenericThread::GetStackEnd(void)
{
thread_info t_thread_info;
GetInfo (& t_thread_info);
GetInfo(& t_thread_info);
return (t_thread_info.stack_end);
}
void
GenericThread::BeginUnit (void)
GenericThread::BeginUnit(void)
{
acquire_sem(m_execute_unit); // thread can not be paused until it releases semaphore
}
void
GenericThread::EndUnit (void)
GenericThread::EndUnit(void)
{
release_sem(m_execute_unit); // thread can now be paused
}
+43 -43
View File
@@ -7,69 +7,69 @@
class GenericThread
{
public:
GenericThread (const char * a_thread_name = "generic_thread", int32 a_priority = B_NORMAL_PRIORITY, BMessage * a_message = NULL);
virtual ~GenericThread (void);
GenericThread(const char * a_thread_name = "generic_thread", int32 a_priority = B_NORMAL_PRIORITY, BMessage * a_message = NULL);
virtual ~GenericThread(void);
BMessage * GetDataStore (void);
void SetDataStore (BMessage * a_message);
BMessage * GetDataStore(void);
void SetDataStore(BMessage * a_message);
status_t Start (void);
status_t Pause (bool a_do_block = TRUE, bigtime_t a_timeout = 0);
void Quit (void);
bool IsPaused (void);
bool HasQuitBeenRequested (void);
status_t Start(void);
status_t Pause(bool a_do_block = TRUE, bigtime_t a_timeout = 0);
void Quit(void);
bool IsPaused(void);
bool HasQuitBeenRequested(void);
status_t Suspend (void);
status_t Resume (void);
status_t Kill (void);
status_t Suspend(void);
status_t Resume(void);
status_t Kill(void);
void ExitWithReturnValue (status_t a_return_value);
status_t SetExitCallback (void (* a_callback)(void *), void * a_data);
status_t WaitForThread (status_t * a_exit_value);
void ExitWithReturnValue(status_t a_return_value);
status_t SetExitCallback(void(* a_callback)(void *), void * a_data);
status_t WaitForThread(status_t * a_exit_value);
status_t Rename (char * a_name);
status_t Rename(char * a_name);
status_t SendData (int32 a_code, void * a_buffer, size_t a_buffer_size);
int32 ReceiveData (thread_id * a_sender, void * a_buffer, size_t a_buffer_size);
bool HasData (void);
status_t SendData(int32 a_code, void * a_buffer, size_t a_buffer_size);
int32 ReceiveData(thread_id * a_sender, void * a_buffer, size_t a_buffer_size);
bool HasData(void);
status_t SetPriority (int32 a_new_priority);
status_t SetPriority(int32 a_new_priority);
void Snooze (bigtime_t a_microseconds);
void SnoozeUntil (bigtime_t a_microseconds, int a_timebase = B_SYSTEM_TIMEBASE);
void Snooze(bigtime_t a_microseconds);
void SnoozeUntil(bigtime_t a_microseconds, int a_timebase = B_SYSTEM_TIMEBASE);
status_t GetInfo (thread_info * a_thread_info);
thread_id GetThread (void);
team_id GetTeam (void);
char * GetName (void);
thread_state GetState (void);
sem_id GetSemaphore (void);
int32 GetPriority (void);
bigtime_t GetUserTime (void);
bigtime_t GetKernelTime (void);
void * GetStackBase (void);
void * GetStackEnd (void);
status_t GetInfo(thread_info * a_thread_info);
thread_id GetThread(void);
team_id GetTeam(void);
char * GetName(void);
thread_state GetState(void);
sem_id GetSemaphore(void);
int32 GetPriority(void);
bigtime_t GetUserTime(void);
bigtime_t GetKernelTime(void);
void * GetStackBase(void);
void * GetStackEnd(void);
protected:
virtual status_t ThreadFunction (void);
virtual status_t ThreadStartup (void);
virtual status_t ExecuteUnit (void);
virtual status_t ThreadShutdown (void);
virtual status_t ThreadFunction(void);
virtual status_t ThreadStartup(void);
virtual status_t ExecuteUnit(void);
virtual status_t ThreadShutdown(void);
virtual void ThreadStartupFailed (status_t a_status);
virtual void ExecuteUnitFailed (status_t a_status);
virtual void ThreadShutdownFailed (status_t a_status);
virtual void ThreadStartupFailed(status_t a_status);
virtual void ExecuteUnitFailed(status_t a_status);
virtual void ThreadShutdownFailed(status_t a_status);
void BeginUnit (void); // acquire m_execute_cycle
void EndUnit (void); // release m_execute_cycle
void BeginUnit(void); // acquire m_execute_cycle
void EndUnit(void); // release m_execute_cycle
BMessage * m_thread_data_store;
private:
static status_t private_thread_function (void * a_simple_thread_ptr);
static status_t private_thread_function(void * a_simple_thread_ptr);
thread_id m_thread_id;