Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 30 Jan 2002 16:46:55 -0500
From:      The Anarcat <anarcat@anarcat.dyndns.org>
To:        Libh <freebsd-libh@freebsd.org>, Alexander Langer <alex@big.endian.de>
Subject:   making Database::create the "default" Database tclh command and Exceptions
Message-ID:  <20020130214652.GA441@shall.anarcat.dyndns.org>

next in thread | raw e-mail | index | archive | help

--UlVJffcvxoiEqYs2
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

Hi.

I'm currently working to start looking around the packaging code, and i
have something I think could be implemented and be quite helpful.

I've been able to implement the default directory thing without big
problems. In the making, I noticed that the Database::open and
Database::create are just stubs to the Database() constructor.

I think it could be a good idea to have the tcl "Database" command
(defined in lib/sysinstall/Database.cd.cc) call Database::create instead
of Database::open. Both functions perform almost the same tasks, except
that Database::create allows creation of the database if missing.

That would allow pkg tools to avoid handling cases where the database is
not created.

It would imply some modifications to the code, of course, but not only
to the .cd.cc file. The Database() constructor needs to know that the
database indeed exist. The best way to do this, IMHO, is to use
exceptions.

I hesitate to assume that a runtime_exception coming out of
Database::create().=20

Also, exceptions is a proper way to handle many conditions in C++ and
nothing keeps us from making extra exception namespaces for libh.

Anyways, here's the patches to deal with this. Right now, it doesn't
implement extra exception namespaces, but this is not too hard.

--- Database.cc	2002/01/21 21:44:52	1.4
+++ Database.cc	2002/01/30 21:42:51
@@ -83,7 +83,11 @@
           addSYSTEMpackage &=3D mOpenFlag =3D=3D ofCreate;
           if ( mOpenFlag =3D=3D ofCreate ) {
                mOpenFlag =3D ofReadWrite;
-               create();
+	       try {
+		       create();
+	       } catch (...) {
+		      =20
+	       }
           }
=20
           engine().lock();

--- Database.cd.cc	2002/01/21 21:44:52	1.6
+++ Database.cd.cc	2002/01/30 21:45:28
@@ -55,7 +55,7 @@
 						   "Configuration::instance()->dbPath()",
 						   "base_dir")),
=20
-	MethodDescription("Database", "open",
+	MethodDescription("Database", "create",
 			  LanguageInterface::Object::MethodDescription::fStatic,
 			  "Opens existing Database",
 			  MethodDescription::Value(MethodDescription::vtObject,


A.

--UlVJffcvxoiEqYs2
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (FreeBSD)
Comment: For info see http://www.gnupg.org

iEYEARECAAYFAjxYacsACgkQttcWHAnWiGcIdgCfdPugMzBAmxYnvtFyZwyyeEYl
hcMAn1AK1uGNY2EAemBywSWw4yJYbxjy
=UXmZ
-----END PGP SIGNATURE-----

--UlVJffcvxoiEqYs2--

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-libh" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020130214652.GA441>