* Renamed: MainModel -> Model, MainModelLoader -> ModelLoader
* Some debug cleanup in ModelLoader. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30283 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -7,9 +7,9 @@ Application DebugAnalyzer
|
|||||||
:
|
:
|
||||||
DataSource.cpp
|
DataSource.cpp
|
||||||
DebugAnalyzer.cpp
|
DebugAnalyzer.cpp
|
||||||
MainModel.cpp
|
|
||||||
MainModelLoader.cpp
|
|
||||||
MainWindow.cpp
|
MainWindow.cpp
|
||||||
|
Model.cpp
|
||||||
|
ModelLoader.cpp
|
||||||
ThreadsPage.cpp
|
ThreadsPage.cpp
|
||||||
|
|
||||||
: libcolumnlistview.a libdebug.so be
|
: libcolumnlistview.a libdebug.so be
|
||||||
|
|||||||
@@ -14,9 +14,9 @@
|
|||||||
#include <AutoLocker.h>
|
#include <AutoLocker.h>
|
||||||
|
|
||||||
#include "DataSource.h"
|
#include "DataSource.h"
|
||||||
#include "MainModel.h"
|
|
||||||
#include "MainModelLoader.h"
|
|
||||||
#include "MessageCodes.h"
|
#include "MessageCodes.h"
|
||||||
|
#include "Model.h"
|
||||||
|
#include "ModelLoader.h"
|
||||||
#include "ThreadsPage.h"
|
#include "ThreadsPage.h"
|
||||||
|
|
||||||
|
|
||||||
@@ -41,7 +41,7 @@ MainWindow::MainWindow(DataSource* dataSource)
|
|||||||
|
|
||||||
// create a model loader, if we have a data source
|
// create a model loader, if we have a data source
|
||||||
if (dataSource != NULL)
|
if (dataSource != NULL)
|
||||||
fModelLoader = new MainModelLoader(dataSource, BMessenger(this), NULL);
|
fModelLoader = new ModelLoader(dataSource, BMessenger(this), NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -59,7 +59,7 @@ MainWindow::MessageReceived(BMessage* message)
|
|||||||
case MSG_MODEL_LOADED_SUCCESSFULLY:
|
case MSG_MODEL_LOADED_SUCCESSFULLY:
|
||||||
{
|
{
|
||||||
printf("MSG_MODEL_LOADED_SUCCESSFULLY\n");
|
printf("MSG_MODEL_LOADED_SUCCESSFULLY\n");
|
||||||
MainModel* model = fModelLoader->DetachModel();
|
Model* model = fModelLoader->DetachModel();
|
||||||
delete fModelLoader;
|
delete fModelLoader;
|
||||||
fModelLoader = NULL;
|
fModelLoader = NULL;
|
||||||
|
|
||||||
@@ -113,7 +113,7 @@ MainWindow::Show()
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
MainWindow::_SetModel(MainModel* model)
|
MainWindow::_SetModel(Model* model)
|
||||||
{
|
{
|
||||||
delete fModel;
|
delete fModel;
|
||||||
fModel = model;
|
fModel = model;
|
||||||
|
|||||||
@@ -10,8 +10,8 @@
|
|||||||
|
|
||||||
class BTabView;
|
class BTabView;
|
||||||
class DataSource;
|
class DataSource;
|
||||||
class MainModel;
|
class ModelLoader;
|
||||||
class MainModelLoader;
|
class Model;
|
||||||
|
|
||||||
|
|
||||||
class MainWindow : public BWindow {
|
class MainWindow : public BWindow {
|
||||||
@@ -26,12 +26,12 @@ public:
|
|||||||
virtual void Show();
|
virtual void Show();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void _SetModel(MainModel* model);
|
void _SetModel(Model* model);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BTabView* fMainTabView;
|
BTabView* fMainTabView;
|
||||||
MainModel* fModel;
|
Model* fModel;
|
||||||
MainModelLoader* fModelLoader;
|
ModelLoader* fModelLoader;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -3,14 +3,14 @@
|
|||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "MainModel.h"
|
#include "Model.h"
|
||||||
|
|
||||||
|
|
||||||
MainModel::MainModel()
|
Model::Model()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
MainModel::~MainModel()
|
Model::~Model()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -2,18 +2,18 @@
|
|||||||
* Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
|
* Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
#ifndef MAIN_MODEL_H
|
#ifndef MODEL_H
|
||||||
#define MAIN_MODEL_H
|
#define MODEL_H
|
||||||
|
|
||||||
|
|
||||||
class MainModel {
|
class Model {
|
||||||
public:
|
public:
|
||||||
MainModel();
|
Model();
|
||||||
~MainModel();
|
~Model();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif // MAIN_MODEL_H
|
#endif // MODEL_H
|
||||||
+16
-25
@@ -3,7 +3,7 @@
|
|||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "MainModelLoader.h"
|
#include "ModelLoader.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@@ -17,11 +17,11 @@
|
|||||||
#include <system_profiler_defs.h>
|
#include <system_profiler_defs.h>
|
||||||
|
|
||||||
#include "DataSource.h"
|
#include "DataSource.h"
|
||||||
#include "MainModel.h"
|
|
||||||
#include "MessageCodes.h"
|
#include "MessageCodes.h"
|
||||||
|
#include "Model.h"
|
||||||
|
|
||||||
|
|
||||||
MainModelLoader::MainModelLoader(DataSource* dataSource,
|
ModelLoader::ModelLoader(DataSource* dataSource,
|
||||||
const BMessenger& target, void* targetCookie)
|
const BMessenger& target, void* targetCookie)
|
||||||
:
|
:
|
||||||
fLock("main model loader"),
|
fLock("main model loader"),
|
||||||
@@ -36,7 +36,7 @@ MainModelLoader::MainModelLoader(DataSource* dataSource,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
MainModelLoader::~MainModelLoader()
|
ModelLoader::~ModelLoader()
|
||||||
{
|
{
|
||||||
if (fLoaderThread >= 0) {
|
if (fLoaderThread >= 0) {
|
||||||
Abort();
|
Abort();
|
||||||
@@ -49,7 +49,7 @@ MainModelLoader::~MainModelLoader()
|
|||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
MainModelLoader::StartLoading()
|
ModelLoader::StartLoading()
|
||||||
{
|
{
|
||||||
// check initialization
|
// check initialization
|
||||||
status_t error = fLock.InitCheck();
|
status_t error = fLock.InitCheck();
|
||||||
@@ -62,10 +62,10 @@ MainModelLoader::StartLoading()
|
|||||||
return B_BAD_VALUE;
|
return B_BAD_VALUE;
|
||||||
|
|
||||||
// create a model
|
// create a model
|
||||||
MainModel* model = new(std::nothrow) MainModel;
|
Model* model = new(std::nothrow) Model;
|
||||||
if (model == NULL)
|
if (model == NULL)
|
||||||
return B_NO_MEMORY;
|
return B_NO_MEMORY;
|
||||||
ObjectDeleter<MainModel> modelDeleter(model);
|
ObjectDeleter<Model> modelDeleter(model);
|
||||||
|
|
||||||
// spawn the loader thread
|
// spawn the loader thread
|
||||||
fLoaderThread = spawn_thread(&_LoaderEntry, "main model loader",
|
fLoaderThread = spawn_thread(&_LoaderEntry, "main model loader",
|
||||||
@@ -86,7 +86,7 @@ MainModelLoader::StartLoading()
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
MainModelLoader::Abort()
|
ModelLoader::Abort()
|
||||||
{
|
{
|
||||||
AutoLocker<BLocker> locker(fLock);
|
AutoLocker<BLocker> locker(fLock);
|
||||||
|
|
||||||
@@ -97,15 +97,15 @@ MainModelLoader::Abort()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
MainModel*
|
Model*
|
||||||
MainModelLoader::DetachModel()
|
ModelLoader::DetachModel()
|
||||||
{
|
{
|
||||||
AutoLocker<BLocker> locker(fLock);
|
AutoLocker<BLocker> locker(fLock);
|
||||||
|
|
||||||
if (fModel == NULL || fLoading)
|
if (fModel == NULL || fLoading)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
MainModel* model = fModel;
|
Model* model = fModel;
|
||||||
fModel = NULL;
|
fModel = NULL;
|
||||||
|
|
||||||
return model;
|
return model;
|
||||||
@@ -113,24 +113,21 @@ MainModelLoader::DetachModel()
|
|||||||
|
|
||||||
|
|
||||||
/*static*/ status_t
|
/*static*/ status_t
|
||||||
MainModelLoader::_LoaderEntry(void* data)
|
ModelLoader::_LoaderEntry(void* data)
|
||||||
{
|
{
|
||||||
return ((MainModelLoader*)data)->_Loader();
|
return ((ModelLoader*)data)->_Loader();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
MainModelLoader::_Loader()
|
ModelLoader::_Loader()
|
||||||
{
|
{
|
||||||
printf("MainModelLoader::_Loader()\n");
|
|
||||||
status_t error;
|
status_t error;
|
||||||
try {
|
try {
|
||||||
error = _Load();
|
error = _Load();
|
||||||
} catch(...) {
|
} catch(...) {
|
||||||
printf("MainModelLoader::_Loader(): caught exception\n");
|
|
||||||
error = B_ERROR;
|
error = B_ERROR;
|
||||||
}
|
}
|
||||||
printf("MainModelLoader::_Loader(): _Load() done: %s\n", strerror(error));
|
|
||||||
|
|
||||||
// clean up and notify the target
|
// clean up and notify the target
|
||||||
AutoLocker<BLocker> locker(fLock);
|
AutoLocker<BLocker> locker(fLock);
|
||||||
@@ -157,7 +154,7 @@ printf("MainModelLoader::_Loader(): _Load() done: %s\n", strerror(error));
|
|||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
MainModelLoader::_Load()
|
ModelLoader::_Load()
|
||||||
{
|
{
|
||||||
// get a BDataIO from the data source
|
// get a BDataIO from the data source
|
||||||
BDataIO* io;
|
BDataIO* io;
|
||||||
@@ -174,10 +171,7 @@ MainModelLoader::_Load()
|
|||||||
|
|
||||||
error = input->SetTo(io);
|
error = input->SetTo(io);
|
||||||
if (error != B_OK)
|
if (error != B_OK)
|
||||||
{
|
|
||||||
printf("MainModelLoader::_Load(): initializing the debug input stream failed: %s\n", strerror(error));
|
|
||||||
return error;
|
return error;
|
||||||
}
|
|
||||||
|
|
||||||
// process the events
|
// process the events
|
||||||
uint32 count = 0;
|
uint32 count = 0;
|
||||||
@@ -189,10 +183,7 @@ printf("MainModelLoader::_Load(): initializing the debug input stream failed: %s
|
|||||||
const void* buffer;
|
const void* buffer;
|
||||||
ssize_t bufferSize = input->ReadNextEvent(&event, &cpu, &buffer);
|
ssize_t bufferSize = input->ReadNextEvent(&event, &cpu, &buffer);
|
||||||
if (bufferSize < 0)
|
if (bufferSize < 0)
|
||||||
{
|
|
||||||
printf("MainModelLoader::_Load(): reading event failed: %s\n", strerror(bufferSize));
|
|
||||||
return bufferSize;
|
return bufferSize;
|
||||||
}
|
|
||||||
if (buffer == NULL)
|
if (buffer == NULL)
|
||||||
return B_OK;
|
return B_OK;
|
||||||
|
|
||||||
@@ -212,7 +203,7 @@ printf("MainModelLoader::_Load(): reading event failed: %s\n", strerror(bufferSi
|
|||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
MainModelLoader::_ProcessEvent(uint32 event, uint32 cpu, const void* buffer,
|
ModelLoader::_ProcessEvent(uint32 event, uint32 cpu, const void* buffer,
|
||||||
size_t size)
|
size_t size)
|
||||||
{
|
{
|
||||||
switch (event) {
|
switch (event) {
|
||||||
@@ -12,21 +12,21 @@
|
|||||||
class BDataIO;
|
class BDataIO;
|
||||||
class BDebugEventInputStream;
|
class BDebugEventInputStream;
|
||||||
class DataSource;
|
class DataSource;
|
||||||
class MainModel;
|
class Model;
|
||||||
struct system_profiler_event_header;
|
struct system_profiler_event_header;
|
||||||
|
|
||||||
|
|
||||||
class MainModelLoader {
|
class ModelLoader {
|
||||||
public:
|
public:
|
||||||
MainModelLoader(DataSource* dataSource,
|
ModelLoader(DataSource* dataSource,
|
||||||
const BMessenger& target,
|
const BMessenger& target,
|
||||||
void* targetCookie);
|
void* targetCookie);
|
||||||
~MainModelLoader();
|
~ModelLoader();
|
||||||
|
|
||||||
status_t StartLoading();
|
status_t StartLoading();
|
||||||
void Abort();
|
void Abort();
|
||||||
|
|
||||||
MainModel* DetachModel();
|
Model* DetachModel();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static status_t _LoaderEntry(void* data);
|
static status_t _LoaderEntry(void* data);
|
||||||
@@ -37,7 +37,7 @@ private:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
BLocker fLock;
|
BLocker fLock;
|
||||||
MainModel* fModel;
|
Model* fModel;
|
||||||
DataSource* fDataSource;
|
DataSource* fDataSource;
|
||||||
BMessenger fTarget;
|
BMessenger fTarget;
|
||||||
void* fTargetCookie;
|
void* fTargetCookie;
|
||||||
Reference in New Issue
Block a user