* 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>
+
+ * 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.
// Where should these live?
#define APPERR_CORRUPT_PACKAGE 1
#define APPERR_IO_ERROR 2
+#define APPERR_LOGIC_ERROR 3
#endif /* _EXCEPTION_H_ */
String++.h \
threebar.cc \
threebar.h \
+ UserSetting.cc \
+ UserSetting.h \
+ UserSettings.cc \
+ UserSettings.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 \
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 =
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
@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 \
@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@
--- /dev/null
+/*
+ * 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);
+}
--- /dev/null
+/*
+ * 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_ */
--- /dev/null
+/*
+ * 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);
+}
--- /dev/null
+/*
+ * 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_ */
StringOption SiteOption("", 's', "site", "Download site");
+/* XXX make into a singleton? */
+static SiteSetting ChosenSites;
+
void
site_list_type::init (String const &newurl)
{
void save_site_url ();
+#include "UserSetting.h"
+class SiteSetting : public UserSetting
+{
+ public:
+};
+
#endif /* _SITE_H_ */