]> cygwin.com Git - cygwin-apps/setup.git/commitdiff
2003-03-10 Robert Collins <rbtcollins@hotmail.com>
authorRobert Collins <rbtcollins@hotmail.com>
Mon, 10 Mar 2003 08:50:16 +0000 (08:50 +0000)
committerRobert Collins <rbtcollins@hotmail.com>
Mon, 10 Mar 2003 08:50:16 +0000 (08:50 +0000)
* Exception.h: Add a logic error exception id.
* Makefile.am: Add new sources.
* UserSettings.cc: New file.
* UserSettings.h: New file.
* UserSetting.cc: New file.
* UserSetting.h: New file.
* site.h: Add a SiteSetting as example of a UserSetting.
* site.cc (ChosenSites): Add a instance of SiteSetting to trigger registration.

ChangeLog
Exception.h
Makefile.am
Makefile.in
UserSetting.cc [new file with mode: 0644]
UserSetting.h [new file with mode: 0644]
UserSettings.cc [new file with mode: 0644]
UserSettings.h [new file with mode: 0644]
site.cc
site.h

index 18702e64bf7a4490a846946b2c40a8c8f9a3591b..1994db3833436ff4a1ea56cc96cf239c7be54b29 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2003-03-10  Robert Collins  <rbtcollins@hotmail.com>
+
+       * Exception.h: Add a logic error exception id.
+       * Makefile.am: Add new sources.
+       * UserSettings.cc: New file.
+       * UserSettings.h: New file.
+       * UserSetting.cc: New file.
+       * UserSetting.h: New file.
+       * site.h: Add a SiteSetting as example of a UserSetting.
+       * site.cc (ChosenSites): Add a instance of SiteSetting to trigger registration.
+
 2003-03-10  Robert Collins  <rbtcollins@hotmail.com>
 
        * compress_bz.cc (compress_bz::read): adjust incorrect assignment of lasterr.
index 3fb7a70705897a31e32ee30adf499a2c04a8f74f..4ace3b39628111a3d0b40172ad23bd4f047eac75 100644 (file)
@@ -39,5 +39,6 @@ private:
 // Where should these live?
 #define APPERR_CORRUPT_PACKAGE 1
 #define APPERR_IO_ERROR                2
+#define APPERR_LOGIC_ERROR     3
 
 #endif /* _EXCEPTION_H_ */
index 8dc63ad6c028334fff3954a5ee9aef408a41e998..6b16ea95f3e5f1d06ec44b163d8df8b0afe57fd3 100644 (file)
@@ -266,6 +266,10 @@ setup_SOURCES = \
        String++.h \
        threebar.cc \
        threebar.h \
+       UserSetting.cc \
+       UserSetting.h \
+       UserSettings.cc \
+       UserSettings.h \
        version.cc \
        version.h \
        win32.cc \
index 1a24370150862c9a0d8b9a54595b06cba9145e93..b858bebe849555d54cbdb7da5bb7ccaa681b7e16 100644 (file)
@@ -409,6 +409,10 @@ setup_SOURCES = \
        String++.h \
        threebar.cc \
        threebar.h \
+       UserSetting.cc \
+       UserSetting.h \
+       UserSettings.cc \
+       UserSettings.h \
        version.cc \
        version.h \
        win32.cc \
@@ -476,7 +480,8 @@ am__setup_SOURCES_DIST = AntiVirus.cc AntiVirus.h archive.cc archive.h \
        root.h ScanFindVisitor.cc ScanFindVisitor.h script.cc script.h \
        setup_version.c simpsock.cc simpsock.h site.cc site.h source.cc \
        source.h splash.cc splash.h state.cc state.h String++.cc \
-       String++.h threebar.cc threebar.h version.cc version.h win32.cc \
+       String++.h threebar.cc threebar.h UserSetting.cc UserSetting.h \
+       UserSettings.cc UserSettings.h version.cc version.h win32.cc \
        win32.h window.cc window.h io_stream_rsync.cc io_stream_rsync.h
 @ENABLERSYNC_TRUE@am__objects_2 = io_stream_rsync.$(OBJEXT)
 @ENABLERSYNC_FALSE@am__objects_2 =
@@ -508,8 +513,8 @@ am_setup_OBJECTS = AntiVirus.$(OBJEXT) archive.$(OBJEXT) \
        script.$(OBJEXT) setup_version.$(OBJEXT) simpsock.$(OBJEXT) \
        site.$(OBJEXT) source.$(OBJEXT) splash.$(OBJEXT) \
        state.$(OBJEXT) String++.$(OBJEXT) threebar.$(OBJEXT) \
-       version.$(OBJEXT) win32.$(OBJEXT) window.$(OBJEXT) \
-       $(am__objects_2)
+       UserSetting.$(OBJEXT) UserSettings.$(OBJEXT) version.$(OBJEXT) \
+       win32.$(OBJEXT) window.$(OBJEXT) $(am__objects_2)
 setup_OBJECTS = $(am_setup_OBJECTS)
 setup_DEPENDENCIES = res.o zlib/libzcygw.a bz2lib/libbz2.a \
        libgetopt++/libgetopt++.la
@@ -531,7 +536,8 @@ am__depfiles_maybe = depfiles
 @AMDEP_TRUE@   ./$(DEPDIR)/PickPackageLine.Po \
 @AMDEP_TRUE@   ./$(DEPDIR)/PickView.Po \
 @AMDEP_TRUE@   ./$(DEPDIR)/ScanFindVisitor.Po \
-@AMDEP_TRUE@   ./$(DEPDIR)/String++.Po ./$(DEPDIR)/archive.Po \
+@AMDEP_TRUE@   ./$(DEPDIR)/String++.Po ./$(DEPDIR)/UserSetting.Po \
+@AMDEP_TRUE@   ./$(DEPDIR)/UserSettings.Po ./$(DEPDIR)/archive.Po \
 @AMDEP_TRUE@   ./$(DEPDIR)/archive_tar.Po \
 @AMDEP_TRUE@   ./$(DEPDIR)/archive_tar_file.Po \
 @AMDEP_TRUE@   ./$(DEPDIR)/autoload.Po ./$(DEPDIR)/category.Po \
@@ -656,6 +662,8 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PickView.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ScanFindVisitor.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/String++.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/UserSetting.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/UserSettings.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/archive.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/archive_tar.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/archive_tar_file.Po@am__quote@
diff --git a/UserSetting.cc b/UserSetting.cc
new file mode 100644 (file)
index 0000000..8aecb47
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2003, Robert Collins
+ *
+ *     This program is free software; you can redistribute it and/or modify
+ *     it under the terms of the GNU General Public License as published by
+ *     the Free Software Foundation; either version 2 of the License, or
+ *     (at your option) any later version.
+ *
+ *     A copy of the GNU General Public License can be found at
+ *     http://www.gnu.org/
+ *
+ * Written by Robert Collins <rbtcollins@hotmail.com>
+ *
+ */
+
+#if 0
+static const char *cvsid =
+  "\n%%% $Id$\n";
+#endif
+
+#include "site.h"
+#include "win32.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <process.h>
+#include <algorithm>
+
+#include "LogSingleton.h"
+#include "io_stream.h"
+
+#include "port.h"
+#include "Exception.h"
+#include "UserSetting.h"
+#include "UserSettings.h"
+
+using namespace std;
+
+UserSetting::UserSetting() 
+{
+  UserSettings::Instance().registerSetting(*this);
+}
+
+UserSetting::~UserSetting() 
+{
+  UserSettings::Instance().deRegisterSetting(*this);
+}
diff --git a/UserSetting.h b/UserSetting.h
new file mode 100644 (file)
index 0000000..3db09e0
--- /dev/null
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2003, Robert Collins.
+ *
+ *     This program is free software; you can redistribute it and/or modify
+ *     it under the terms of the GNU General Public License as published by
+ *     the Free Software Foundation; either version 2 of the License, or
+ *     (at your option) any later version.
+ *
+ *     A copy of the GNU General Public License can be found at
+ *     http://www.gnu.org/
+ *
+ * Written by Robert Collins  <rbtcollins@hotmail.com>
+ *
+ */
+
+/* A user-related settings */
+
+#ifndef _USERSETTING_H_
+#define _USERSETTING_H_
+
+class UserSetting {
+  public:
+  UserSetting();
+  virtual ~UserSetting();
+};
+
+#endif /* _USERSETTING_H_ */
diff --git a/UserSettings.cc b/UserSettings.cc
new file mode 100644 (file)
index 0000000..eae5fa4
--- /dev/null
@@ -0,0 +1,68 @@
+/*
+ * Copyright (c) 2003, Robert Collins
+ *
+ *     This program is free software; you can redistribute it and/or modify
+ *     it under the terms of the GNU General Public License as published by
+ *     the Free Software Foundation; either version 2 of the License, or
+ *     (at your option) any later version.
+ *
+ *     A copy of the GNU General Public License can be found at
+ *     http://www.gnu.org/
+ *
+ * Written by Robert Collins <rbtcollins@hotmail.com>
+ *
+ */
+
+#if 0
+static const char *cvsid =
+  "\n%%% $Id$\n";
+#endif
+
+#include "site.h"
+#include "win32.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <process.h>
+#include <algorithm>
+
+#include "LogSingleton.h"
+#include "io_stream.h"
+
+#include "port.h"
+#include "Exception.h"
+#include "UserSettings.h"
+
+using namespace std;
+
+UserSettings &
+UserSettings::Instance()
+{
+  return Instance_;
+  if (Instance_.inited != 42)
+      Instance_.init ();
+  return Instance_;
+}
+
+void
+UserSettings::init ()
+{
+  inited = 42;
+}
+
+UserSettings UserSettings::Instance_;
+
+void
+UserSettings::registerSetting(UserSetting &aSetting)
+{
+  settings.push_back(&aSetting);
+}
+
+void
+UserSettings::deRegisterSetting(UserSetting &aSetting)
+{
+  Settings::iterator i = find(settings.begin(), settings.end(), &aSetting);
+  if (i == settings.end())
+    throw new Exception ("__LINE__ __FILE__", String ("Attempt to deregister non registered setting!"), APPERR_LOGIC_ERROR);
+  settings.erase(i);
+}
diff --git a/UserSettings.h b/UserSettings.h
new file mode 100644 (file)
index 0000000..e02e9a4
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2003, Robert Collins.
+ *
+ *     This program is free software; you can redistribute it and/or modify
+ *     it under the terms of the GNU General Public License as published by
+ *     the Free Software Foundation; either version 2 of the License, or
+ *     (at your option) any later version.
+ *
+ *     A copy of the GNU General Public License can be found at
+ *     http://www.gnu.org/
+ *
+ * Written by Robert Collins  <rbtcollins@hotmail.com>
+ *
+ */
+
+/* A collection of user-related settings */
+
+#ifndef _USERSETTINGS_H_
+#define _USERSETTINGS_H_
+
+#include <vector>
+
+class UserSetting;
+class UserSettings {
+  public:
+    static UserSettings &Instance();
+    void registerSetting(UserSetting &);
+    void deRegisterSetting(UserSetting &);
+  private:
+    static UserSettings Instance_;
+    typedef std::vector<UserSetting *> Settings;
+    void init();
+    int inited;
+    Settings settings;
+};
+
+#endif /* _USERSETTINGS_H_ */
diff --git a/site.cc b/site.cc
index 43961a62c31cd4f7a3d97fbf7b9d04821c093d9d..8dc0c1b01baafbe859e4d2f33640ac2690e19fea 100644 (file)
--- a/site.cc
+++ b/site.cc
@@ -54,6 +54,9 @@ SiteList all_site_list;
 
 StringOption SiteOption("", 's', "site", "Download site");
 
+/* XXX make into a singleton? */
+static SiteSetting ChosenSites;
+
 void
 site_list_type::init (String const &newurl)
 {
diff --git a/site.h b/site.h
index 6866c77e77cd70cc4e14241ec3e50498bb1cfdf1..c0028d6ed557257ecca4ea6ac9d4e71009359e90 100644 (file)
--- a/site.h
+++ b/site.h
@@ -82,4 +82,10 @@ extern SiteList all_site_list;
 
 void save_site_url ();
 
+#include "UserSetting.h"
+class SiteSetting : public UserSetting 
+{
+  public:
+};
+
 #endif /* _SITE_H_ */
This page took 0.047757 seconds and 5 git commands to generate.