[Lemon-commits] Alpar Juttner: Merge
Lemon HG
hg at lemon.cs.elte.hu
Thu Mar 20 13:13:47 CET 2008
details: http://lemon.cs.elte.hu/hg/lemon/rev/dbaa96cc1013
changeset: 99:dbaa96cc1013
user: Alpar Juttner <alpar [at] cs.elte.hu>
date: Thu Feb 07 21:28:39 2008 +0000
description:
Merge
diffstat:
8 files changed, 832 insertions(+), 4 deletions(-)
configure.ac | 2
lemon/Makefile.am | 4
lemon/concepts/digraph.h | 33 ++
lemon/concepts/graph.h | 49 +++
lemon/error.h | 675 ++++++++++++++++++++++++++++++++++++++++++++++
lemon/random.h | 2
test/Makefile.am | 3
test/error_test.cc | 68 ++++
diffs (truncated from 946 to 300 lines):
diff -r c4582fc14f58 -r dbaa96cc1013 configure.ac
--- a/configure.ac Thu Jan 24 17:36:45 2008 +0000
+++ b/configure.ac Thu Feb 07 21:28:39 2008 +0000
@@ -13,7 +13,7 @@ AC_INIT([LEMON], [lemon_version()], [eti
AC_INIT([LEMON], [lemon_version()], [etik-ol at cs.elte.hu], [lemon])
AC_CONFIG_AUX_DIR([build-aux])
AC_CONFIG_MACRO_DIR([m4])
-AM_INIT_AUTOMAKE([-Wall -Werror foreign subdir-objects])
+AM_INIT_AUTOMAKE([-Wall -Werror foreign subdir-objects nostdinc])
AC_CONFIG_SRCDIR([lemon/list_graph.h])
AC_CONFIG_HEADERS([config.h lemon/config.h])
diff -r c4582fc14f58 -r dbaa96cc1013 lemon/Makefile.am
--- a/lemon/Makefile.am Thu Jan 24 17:36:45 2008 +0000
+++ b/lemon/Makefile.am Thu Feb 07 21:28:39 2008 +0000
@@ -15,11 +15,13 @@ lemon_libemon_la_LDFLAGS = $(GLPK_LIBS)
lemon_libemon_la_LDFLAGS = $(GLPK_LIBS) $(CPLEX_LIBS) $(SOPLEX_LIBS)
lemon_HEADERS += \
+ lemon/concept_check.h \
lemon/dim2.h \
+ lemon/error.h \
+ lemon/list_graph.h \
lemon/maps.h \
lemon/path.h \
lemon/random.h \
- lemon/list_graph.h \
lemon/tolerance.h
bits_HEADERS += \
diff -r c4582fc14f58 -r dbaa96cc1013 lemon/concepts/digraph.h
--- a/lemon/concepts/digraph.h Thu Jan 24 17:36:45 2008 +0000
+++ b/lemon/concepts/digraph.h Thu Feb 07 21:28:39 2008 +0000
@@ -348,6 +348,28 @@ namespace lemon {
///
Node source(Arc) const { return INVALID; }
+ /// \brief Returns the ID of the node.
+ int id(Node) const { return -1; }
+
+ /// \brief Returns the ID of the arc.
+ int id(Arc) const { return -1; }
+
+ /// \brief Returns the node with the given ID.
+ ///
+ /// \pre The argument should be a valid node ID in the graph.
+ Node nodeFromId(int) const { return INVALID; }
+
+ /// \brief Returns the arc with the given ID.
+ ///
+ /// \pre The argument should be a valid arc ID in the graph.
+ Arc arcFromId(int) const { return INVALID; }
+
+ /// \brief Returns an upper bound on the node IDs.
+ int maxNodeId() const { return -1; }
+
+ /// \brief Returns an upper bound on the arc IDs.
+ int maxArcId() const { return -1; }
+
void first(Node&) const {}
void next(Node&) const {}
@@ -360,6 +382,16 @@ namespace lemon {
void firstOut(Arc&, const Node&) const {}
void nextOut(Arc&) const {}
+
+ // The second parameter is dummy.
+ Node fromId(int, Node) const { return INVALID; }
+ // The second parameter is dummy.
+ Arc fromId(int, Arc) const { return INVALID; }
+
+ // Dummy parameter.
+ int maxId(Node) const { return -1; }
+ // Dummy parameter.
+ int maxId(Arc) const { return -1; }
/// \brief The base node of the iterator.
///
@@ -439,6 +471,7 @@ namespace lemon {
struct Constraints {
void constraints() {
checkConcept<IterableDigraphComponent<>, Digraph>();
+ checkConcept<IDableDigraphComponent<>, Digraph>();
checkConcept<MappableDigraphComponent<>, Digraph>();
}
};
diff -r c4582fc14f58 -r dbaa96cc1013 lemon/concepts/graph.h
--- a/lemon/concepts/graph.h Thu Jan 24 17:36:45 2008 +0000
+++ b/lemon/concepts/graph.h Thu Feb 07 21:28:39 2008 +0000
@@ -624,6 +624,39 @@ namespace lemon {
/// \brief Target node of the directed arc.
Node target(Arc) const { return INVALID; }
+ /// \brief Returns the id of the node.
+ int id(Node) const { return -1; }
+
+ /// \brief Returns the id of the edge.
+ int id(Edge) const { return -1; }
+
+ /// \brief Returns the id of the arc.
+ int id(Arc) const { return -1; }
+
+ /// \brief Returns the node with the given id.
+ ///
+ /// \pre The argument should be a valid node id in the graph.
+ Node nodeFromId(int) const { return INVALID; }
+
+ /// \brief Returns the edge with the given id.
+ ///
+ /// \pre The argument should be a valid edge id in the graph.
+ Edge edgeFromId(int) const { return INVALID; }
+
+ /// \brief Returns the arc with the given id.
+ ///
+ /// \pre The argument should be a valid arc id in the graph.
+ Arc arcFromId(int) const { return INVALID; }
+
+ /// \brief Returns an upper bound on the node IDs.
+ int maxNodeId() const { return -1; }
+
+ /// \brief Returns an upper bound on the edge IDs.
+ int maxEdgeId() const { return -1; }
+
+ /// \brief Returns an upper bound on the arc IDs.
+ int maxArcId() const { return -1; }
+
void first(Node&) const {}
void next(Node&) const {}
@@ -639,9 +672,22 @@ namespace lemon {
void firstIn(Arc&, Node) const {}
void nextIn(Arc&) const {}
-
void firstInc(Edge &, bool &, const Node &) const {}
void nextInc(Edge &, bool &) const {}
+
+ // The second parameter is dummy.
+ Node fromId(int, Node) const { return INVALID; }
+ // The second parameter is dummy.
+ Edge fromId(int, Edge) const { return INVALID; }
+ // The second parameter is dummy.
+ Arc fromId(int, Arc) const { return INVALID; }
+
+ // Dummy parameter.
+ int maxId(Node) const { return -1; }
+ // Dummy parameter.
+ int maxId(Edge) const { return -1; }
+ // Dummy parameter.
+ int maxId(Arc) const { return -1; }
/// \brief Base node of the iterator
///
@@ -689,6 +735,7 @@ namespace lemon {
struct Constraints {
void constraints() {
checkConcept<IterableGraphComponent<>, Graph>();
+ checkConcept<IDableGraphComponent<>, Graph>();
checkConcept<MappableGraphComponent<>, Graph>();
}
};
diff -r c4582fc14f58 -r dbaa96cc1013 lemon/error.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/lemon/error.h Thu Feb 07 21:28:39 2008 +0000
@@ -0,0 +1,675 @@
+/* -*- C++ -*-
+ *
+ * This file is a part of LEMON, a generic C++ optimization library
+ *
+ * Copyright (C) 2003-2008
+ * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
+ * (Egervary Research Group on Combinatorial Optimization, EGRES).
+ *
+ * Permission to use, modify and distribute this software is granted
+ * provided that this copyright notice appears in all copies. For
+ * precise terms see the accompanying LICENSE file.
+ *
+ * This software is provided "AS IS" with no warranty of any kind,
+ * express or implied, and with no claim as to its suitability for any
+ * purpose.
+ *
+ */
+
+#ifndef LEMON_ERROR_H
+#define LEMON_ERROR_H
+
+/// \ingroup exceptions
+/// \file
+/// \brief Basic exception classes and error handling.
+
+#include <exception>
+#include <string>
+#include <sstream>
+#include <iostream>
+#include <cstdlib>
+#include <memory>
+
+namespace lemon {
+
+ /// \addtogroup exceptions
+ /// @{
+
+ /// \brief Exception safe wrapper class.
+ ///
+ /// Exception safe wrapper class to implement the members of exceptions.
+ template <typename _Type>
+ class ExceptionMember {
+ public:
+ typedef _Type Type;
+
+ ExceptionMember() throw() {
+ try {
+ ptr.reset(new Type());
+ } catch (...) {}
+ }
+
+ ExceptionMember(const Type& type) throw() {
+ try {
+ ptr.reset(new Type());
+ if (ptr.get() == 0) return;
+ *ptr = type;
+ } catch (...) {}
+ }
+
+ ExceptionMember(const ExceptionMember& copy) throw() {
+ try {
+ if (!copy.valid()) return;
+ ptr.reset(new Type());
+ if (ptr.get() == 0) return;
+ *ptr = copy.get();
+ } catch (...) {}
+ }
+
+ ExceptionMember& operator=(const ExceptionMember& copy) throw() {
+ if (ptr.get() == 0) return;
+ try {
+ if (!copy.valid()) return;
+ *ptr = copy.get();
+ } catch (...) {}
+ }
+
+ void set(const Type& type) throw() {
+ if (ptr.get() == 0) return;
+ try {
+ *ptr = type;
+ } catch (...) {}
+ }
+
+ const Type& get() const {
+ return *ptr;
+ }
+
+ bool valid() const throw() {
+ return ptr.get() != 0;
+ }
+
+ private:
+ std::auto_ptr<_Type> ptr;
+ };
+
+ /// Exception-safe convenient "error message" class.
+
+ /// Helper class which provides a convenient ostream-like (operator <<
+ /// based) interface to create a string message. Mostly useful in
+ /// exception classes (therefore the name).
+ class ErrorMessage {
+ protected:
+ ///\e
+
+ ///\todo The good solution is boost::shared_ptr...
+ ///
+ mutable std::auto_ptr<std::ostringstream> buf;
+
+ ///\e
+ bool init() throw() {
+ try {
+ buf.reset(new std::ostringstream);
+ }
+ catch(...) {
+ buf.reset();
+ }
+ return buf.get();
+ }
+
+ public:
+
+ ///\e
+ ErrorMessage() throw() { init(); }
+
+ ErrorMessage(const ErrorMessage& em) throw() : buf(em.buf) { }
+
+ ///\e
+ ErrorMessage(const char *msg) throw() {
+ init();
+ *this << msg;
+ }
+
+ ///\e
+ ErrorMessage(const std::string &msg) throw() {
More information about the Lemon-commits
mailing list