WIP: Add abstract base class TeamUISettings and corresponding subclass GUITeamUISettings.
Once complete, these will be used to store/restore settings for the debugger's various UI components. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@43060 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -140,8 +140,10 @@ Application Debugger :
|
||||
|
||||
# settings
|
||||
BreakpointSetting.cpp
|
||||
TeamSettings.cpp
|
||||
SettingsManager.cpp
|
||||
TeamSettings.cpp
|
||||
TeamUISettings.cpp
|
||||
GUITeamUISettings.cpp
|
||||
|
||||
# settings/generic
|
||||
Setting.cpp
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
* Copyright 2011, Rene Gollent, [email protected].
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#include "GUITeamUISettings.h"
|
||||
|
||||
#include <Message.h>
|
||||
|
||||
|
||||
GUITeamUISettings::GUITeamUISettings(const char* settingsID)
|
||||
:
|
||||
fID(settingsID)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
GUITeamUISettings::GUITeamUISettings(const GUITeamUISettings& other)
|
||||
{
|
||||
fID = other.fID;
|
||||
}
|
||||
|
||||
|
||||
GUITeamUISettings::~GUITeamUISettings()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
const char*
|
||||
GUITeamUISettings::ID() const
|
||||
{
|
||||
return fID.String();
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
GUITeamUISettings::SetTo(const BMessage& archive)
|
||||
{
|
||||
status_t error = archive.FindString("ID", &fID);
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
GUITeamUISettings::WriteTo(BMessage& archive) const
|
||||
{
|
||||
status_t error = archive.AddString("ID", fID);
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
TeamUISettings*
|
||||
GUITeamUISettings::Clone() const
|
||||
{
|
||||
GUITeamUISettings* settings = new GUITeamUISettings(fID.String());
|
||||
|
||||
return settings;
|
||||
}
|
||||
|
||||
|
||||
GUITeamUISettings&
|
||||
GUITeamUISettings::operator=(const GUITeamUISettings& other)
|
||||
{
|
||||
fID = other.fID;
|
||||
return *this;
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright 2011, Rene Gollent, [email protected].
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef GUI_TEAM_UI_SETTINGS_H
|
||||
#define GUI_TEAM_UI_SETTINGS_H
|
||||
|
||||
|
||||
#include <String.h>
|
||||
|
||||
#include <ObjectList.h>
|
||||
|
||||
#include "TeamUISettings.h"
|
||||
|
||||
class BMessage;
|
||||
|
||||
|
||||
class GUITeamUISettings : public TeamUISettings {
|
||||
public:
|
||||
GUITeamUISettings(const char* settingsID);
|
||||
GUITeamUISettings(const GUITeamUISettings&
|
||||
other);
|
||||
// throws std::bad_alloc
|
||||
~GUITeamUISettings();
|
||||
|
||||
virtual const char* ID() const;
|
||||
virtual status_t SetTo(const BMessage& archive);
|
||||
virtual status_t WriteTo(BMessage& archive) const;
|
||||
virtual TeamUISettings* Clone() const;
|
||||
|
||||
GUITeamUISettings& operator=(const GUITeamUISettings& other);
|
||||
// throws std::bad_alloc
|
||||
|
||||
private:
|
||||
|
||||
BString fID;
|
||||
};
|
||||
|
||||
|
||||
#endif // GUI_TEAM_UI_SETTINGS_H
|
||||
@@ -15,6 +15,7 @@
|
||||
#include "ArchivingUtils.h"
|
||||
#include "BreakpointSetting.h"
|
||||
#include "Team.h"
|
||||
#include "TeamUISettings.h"
|
||||
#include "UserBreakpoint.h"
|
||||
|
||||
|
||||
@@ -98,6 +99,12 @@ TeamSettings::SetTo(const BMessage& archive)
|
||||
return error;
|
||||
}
|
||||
}
|
||||
|
||||
// add UI settings
|
||||
for (int32 i = 0; archive.FindMessage("uisettings", i, &childArchive)
|
||||
== B_OK; i++) {
|
||||
|
||||
}
|
||||
|
||||
return B_OK;
|
||||
}
|
||||
@@ -140,6 +147,20 @@ TeamSettings::BreakpointAt(int32 index) const
|
||||
}
|
||||
|
||||
|
||||
int32
|
||||
TeamSettings::CountUISettings() const
|
||||
{
|
||||
return fUISettings.CountItems();
|
||||
}
|
||||
|
||||
|
||||
const TeamUISettings*
|
||||
TeamSettings::UISettingAt(int32 index) const
|
||||
{
|
||||
return fUISettings.ItemAt(index);
|
||||
}
|
||||
|
||||
|
||||
TeamSettings&
|
||||
TeamSettings::operator=(const TeamSettings& other)
|
||||
{
|
||||
@@ -160,6 +181,16 @@ TeamSettings::operator=(const TeamSettings& other)
|
||||
}
|
||||
}
|
||||
|
||||
for (int32 i = 0; TeamUISettings* uiSetting
|
||||
= other.fUISettings.ItemAt(i); i++) {
|
||||
TeamUISettings* clonedSetting
|
||||
= uiSetting->Clone();
|
||||
if (!fUISettings.AddItem(clonedSetting)) {
|
||||
delete clonedSetting;
|
||||
throw std::bad_alloc();
|
||||
}
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -171,7 +202,12 @@ TeamSettings::_Unset()
|
||||
i++) {
|
||||
delete breakpoint;
|
||||
}
|
||||
|
||||
for (int32 i = 0; TeamUISettings* uiSetting = fUISettings.ItemAt(i); i++)
|
||||
delete uiSetting;
|
||||
|
||||
fBreakpoints.MakeEmpty();
|
||||
fUISettings.MakeEmpty();
|
||||
|
||||
fTeamName.Truncate(0);
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
class BMessage;
|
||||
class Team;
|
||||
class BreakpointSetting;
|
||||
class TeamUISettings;
|
||||
|
||||
|
||||
class TeamSettings {
|
||||
@@ -31,18 +32,23 @@ public:
|
||||
|
||||
int32 CountBreakpoints() const;
|
||||
const BreakpointSetting* BreakpointAt(int32 index) const;
|
||||
|
||||
int32 CountUISettings() const;
|
||||
const TeamUISettings* UISettingAt(int32 index) const;
|
||||
|
||||
TeamSettings& operator=(const TeamSettings& other);
|
||||
// throws std::bad_alloc
|
||||
|
||||
private:
|
||||
typedef BObjectList<BreakpointSetting> BreakpointList;
|
||||
typedef BObjectList<TeamUISettings> UISettingsList;
|
||||
|
||||
private:
|
||||
void _Unset();
|
||||
|
||||
private:
|
||||
BreakpointList fBreakpoints;
|
||||
UISettingsList fUISettings;
|
||||
BString fTeamName;
|
||||
};
|
||||
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
/*
|
||||
* Copyright 2011, Rene Gollent, [email protected].
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#include "TeamUISettings.h"
|
||||
|
||||
|
||||
TeamUISettings::TeamUISettings()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
TeamUISettings::~TeamUISettings()
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright 2011, Rene Gollent, [email protected].
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef TEAM_UI_SETTINGS_H
|
||||
#define TEAM_UI_SETTINGS_H
|
||||
|
||||
|
||||
#include <String.h>
|
||||
|
||||
|
||||
class BMessage;
|
||||
|
||||
|
||||
class TeamUISettings {
|
||||
public:
|
||||
TeamUISettings();
|
||||
~TeamUISettings();
|
||||
|
||||
virtual const char* ID() const = 0;
|
||||
virtual status_t SetTo(const BMessage& archive) = 0;
|
||||
virtual status_t WriteTo(BMessage& archive) const = 0;
|
||||
|
||||
virtual TeamUISettings* Clone() const = 0;
|
||||
// throws std::bad_alloc
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif // TEAM_UI_SETTINGS_H
|
||||
Reference in New Issue
Block a user