[haiku-commits] r43067 - in haiku/trunk/src/apps/debugger: . settings

  • From: anevilyak@xxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Tue, 1 Nov 2011 16:45:32 +0100 (CET)

Author: anevilyak
Date: 2011-11-01 16:45:31 +0100 (Tue, 01 Nov 2011)
New Revision: 43067
Changeset: https://dev.haiku-os.org/changeset/43067

Added:
   haiku/trunk/src/apps/debugger/settings/TeamUISettingsFactory.cpp
   haiku/trunk/src/apps/debugger/settings/TeamUISettingsFactory.h
Modified:
   haiku/trunk/src/apps/debugger/Jamfile
   haiku/trunk/src/apps/debugger/settings/GUITeamUISettings.cpp
   haiku/trunk/src/apps/debugger/settings/GUITeamUISettings.h
   haiku/trunk/src/apps/debugger/settings/TeamSettings.cpp
   haiku/trunk/src/apps/debugger/settings/TeamUISettings.h
Log:
More work-in-progress towards getting settings saved/restored.



Modified: haiku/trunk/src/apps/debugger/Jamfile
===================================================================
--- haiku/trunk/src/apps/debugger/Jamfile       2011-11-01 15:02:06 UTC (rev 
43066)
+++ haiku/trunk/src/apps/debugger/Jamfile       2011-11-01 15:45:31 UTC (rev 
43067)
@@ -140,10 +140,11 @@
 
        # settings
        BreakpointSetting.cpp
+       GUITeamUISettings.cpp
        SettingsManager.cpp
        TeamSettings.cpp
        TeamUISettings.cpp
-       GUITeamUISettings.cpp
+       TeamUISettingsFactory.cpp
 
        # settings/generic
        Setting.cpp

Modified: haiku/trunk/src/apps/debugger/settings/GUITeamUISettings.cpp
===================================================================
--- haiku/trunk/src/apps/debugger/settings/GUITeamUISettings.cpp        
2011-11-01 15:02:06 UTC (rev 43066)
+++ haiku/trunk/src/apps/debugger/settings/GUITeamUISettings.cpp        
2011-11-01 15:45:31 UTC (rev 43067)
@@ -7,6 +7,11 @@
 #include <Message.h>
 
 
+GUITeamUISettings::GUITeamUISettings()
+{
+}
+
+
 GUITeamUISettings::GUITeamUISettings(const char* settingsID)
        :
        fID(settingsID)
@@ -25,6 +30,13 @@
 }
 
 
+team_ui_settings_type
+GUITeamUISettings::Type() const
+{
+       return TEAM_UI_SETTINGS_TYPE_GUI;
+}
+
+
 const char*
 GUITeamUISettings::ID() const
 {
@@ -45,6 +57,10 @@
 GUITeamUISettings::WriteTo(BMessage& archive) const
 {
        status_t error = archive.AddString("ID", fID);
+       if (error != B_OK)
+               return error;
+               
+       error = archive.AddInt32("type", Type());
        
        return error;
 }

Modified: haiku/trunk/src/apps/debugger/settings/GUITeamUISettings.h
===================================================================
--- haiku/trunk/src/apps/debugger/settings/GUITeamUISettings.h  2011-11-01 
15:02:06 UTC (rev 43066)
+++ haiku/trunk/src/apps/debugger/settings/GUITeamUISettings.h  2011-11-01 
15:45:31 UTC (rev 43067)
@@ -17,12 +17,14 @@
 
 class GUITeamUISettings : public TeamUISettings {
 public:
+                                                               
GUITeamUISettings();
                                                                
GUITeamUISettings(const char* settingsID);
                                                                
GUITeamUISettings(const GUITeamUISettings&
                                                                        other);
                                                                        // 
throws std::bad_alloc
                                                                
~GUITeamUISettings();
 
+       virtual team_ui_settings_type Type() const;
        virtual const char*                     ID() const;
        virtual status_t                        SetTo(const BMessage& archive);
        virtual status_t                        WriteTo(BMessage& archive) 
const;

Modified: haiku/trunk/src/apps/debugger/settings/TeamSettings.cpp
===================================================================
--- haiku/trunk/src/apps/debugger/settings/TeamSettings.cpp     2011-11-01 
15:02:06 UTC (rev 43066)
+++ haiku/trunk/src/apps/debugger/settings/TeamSettings.cpp     2011-11-01 
15:45:31 UTC (rev 43067)
@@ -16,6 +16,7 @@
 #include "BreakpointSetting.h"
 #include "Team.h"
 #include "TeamUISettings.h"
+#include "TeamUISettingsFactory.h"
 #include "UserBreakpoint.h"
 
 
@@ -103,7 +104,14 @@
        // add UI settings
        for (int32 i = 0; archive.FindMessage("uisettings", i, &childArchive)
                == B_OK; i++) {
-               
+               TeamUISettings* setting = NULL;
+               error = TeamUISettingsFactory::Create(childArchive, setting);
+               if (error == B_OK && !fUISettings.AddItem(setting))
+                       error = B_NO_MEMORY;
+               if (error != B_OK) {
+                       delete setting;
+                       return error;
+               }               
        }
 
        return B_OK;
@@ -117,9 +125,9 @@
        if (error != B_OK)
                return error;
 
+       BMessage childArchive;
        for (int32 i = 0; BreakpointSetting* breakpoint = 
fBreakpoints.ItemAt(i);
                        i++) {
-               BMessage childArchive;
                error = breakpoint->WriteTo(childArchive);
                if (error != B_OK)
                        return error;
@@ -128,6 +136,17 @@
                if (error != B_OK)
                        return error;
        }
+       
+       for (int32 i = 0; TeamUISettings* uiSetting = fUISettings.ItemAt(i);
+                       i++) {
+               error = uiSetting->WriteTo(childArchive);
+               if (error != B_OK)
+                       return error;
+                       
+               error = archive.AddMessage("uisettings", &childArchive);
+               if (error != B_OK)
+                       return error;
+       }
 
        return B_OK;
 }

Modified: haiku/trunk/src/apps/debugger/settings/TeamUISettings.h
===================================================================
--- haiku/trunk/src/apps/debugger/settings/TeamUISettings.h     2011-11-01 
15:02:06 UTC (rev 43066)
+++ haiku/trunk/src/apps/debugger/settings/TeamUISettings.h     2011-11-01 
15:45:31 UTC (rev 43067)
@@ -12,11 +12,18 @@
 class BMessage;
 
 
+enum team_ui_settings_type {
+       TEAM_UI_SETTINGS_TYPE_GUI,
+       TEAM_UI_SETTINGS_TYPE_CLI
+};
+
+
 class TeamUISettings {
 public:
                                                                
TeamUISettings();
        virtual                                         ~TeamUISettings();
 
+       virtual team_ui_settings_type Type() const = 0;
        virtual const char*                     ID() const = 0;
        virtual status_t                        SetTo(const BMessage& archive) 
= 0;
        virtual status_t                        WriteTo(BMessage& archive) 
const = 0;

Added: haiku/trunk/src/apps/debugger/settings/TeamUISettingsFactory.cpp
===================================================================
--- haiku/trunk/src/apps/debugger/settings/TeamUISettingsFactory.cpp            
                (rev 0)
+++ haiku/trunk/src/apps/debugger/settings/TeamUISettingsFactory.cpp    
2011-11-01 15:45:31 UTC (rev 43067)
@@ -0,0 +1,56 @@
+/*
+ * Copyright 2011, Rene Gollent, rene@xxxxxxxxxxxx
+ * Distributed under the terms of the MIT License.
+ */
+ 
+#include "TeamUISettingsFactory.h"
+
+#include <Message.h>
+
+#include "GUITeamUISettings.h"
+
+
+TeamUISettingsFactory::TeamUISettingsFactory()
+{
+}
+
+
+TeamUISettingsFactory::~TeamUISettingsFactory()
+{
+}
+
+
+status_t
+TeamUISettingsFactory::Create(const BMessage& archive, TeamUISettings*& 
+       settings)
+{
+       int32 type;
+       status_t error = archive.FindInt32("type", &type);
+       if (error != B_OK)
+               return error;
+       
+       switch (type) {
+               case TEAM_UI_SETTINGS_TYPE_GUI:
+                       settings = new(std::nothrow) GUITeamUISettings();
+                       if (settings == NULL)
+                               return B_NO_MEMORY;
+
+                       error = settings->SetTo(archive);
+                       if (error != B_OK) {
+                               delete settings;
+                               settings = NULL;
+                               return error;
+                       }
+                       break;
+                       
+               case TEAM_UI_SETTINGS_TYPE_CLI:
+                       // TODO: implement once we have a CLI interface
+                       // (and corresponding settings)
+                       return B_UNSUPPORTED;
+
+               default:
+                       return B_BAD_DATA;
+       }
+       
+       return B_OK;
+}

Added: haiku/trunk/src/apps/debugger/settings/TeamUISettingsFactory.h
===================================================================
--- haiku/trunk/src/apps/debugger/settings/TeamUISettingsFactory.h              
                (rev 0)
+++ haiku/trunk/src/apps/debugger/settings/TeamUISettingsFactory.h      
2011-11-01 15:45:31 UTC (rev 43067)
@@ -0,0 +1,24 @@
+/*
+ * Copyright 2011, Rene Gollent, rene@xxxxxxxxxxxx
+ * Distributed under the terms of the MIT License.
+ */
+#ifndef TEAM_UI_SETTINGS_FACTORY_H
+#define TEAM_UI_SETTINGS_FACTORY_H
+
+
+#include <SupportDefs.h>
+
+
+class BMessage;
+class TeamUISettings;
+
+class TeamUISettingsFactory {
+public:
+                                                               
TeamUISettingsFactory();
+                                                               
~TeamUISettingsFactory();
+                                               
+       static  status_t                        Create(const BMessage& archive,
+                                                                       
TeamUISettings*& settings);
+};
+
+#endif // TEAM_UI_SETTINGS_FACTORY_H


Other related posts:

  • » [haiku-commits] r43067 - in haiku/trunk/src/apps/debugger: . settings - anevilyak