[Lemon-commits] Alpar Juttner: Merge

Lemon HG hg at lemon.cs.elte.hu
Wed Sep 24 16:20:20 CEST 2008


details:   http://lemon.cs.elte.hu/hg/lemon/rev/6307bbbf285b
changeset: 279:6307bbbf285b
user:      Alpar Juttner <alpar [at] cs.elte.hu>
date:      Tue Sep 23 18:42:49 2008 +0200
description:
	Merge

diffstat:

17 files changed, 283 insertions(+), 104 deletions(-)
CMakeLists.txt                    |   18 -----
NEWS                              |   49 +++++++++++++++
configure.ac                      |   10 ++-
doc/Makefile.am                   |    1 
doc/named-param.dox               |  119 +++++++++++++++++++++++++++++++++++++
lemon/arg_parser.h                |    6 -
lemon/assert.h                    |   77 ++++++-----------------
lemon/bits/array_map.h            |    2 
lemon/bits/graph_extender.h       |    5 +
lemon/bits/map_extender.h         |    4 +
lemon/bits/vector_map.h           |    1 
lemon/concepts/digraph.h          |    2 
lemon/concepts/graph.h            |    3 
lemon/concepts/graph_components.h |   15 +++-
scripts/chg-len.py                |   39 ++++++++++++
test/error_test.cc                |   12 ---
test/graph_test.h                 |   24 +++----

diffs (truncated from 768 to 300 lines):

diff -r 931190050520 -r 6307bbbf285b CMakeLists.txt
--- a/CMakeLists.txt	Mon Sep 22 15:33:23 2008 +0200
+++ b/CMakeLists.txt	Tue Sep 23 18:42:49 2008 +0200
@@ -1,16 +1,7 @@
 CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
 
-#EXECUTE_PROCESS(
-#  COMMAND hg id -i
-#  OUTPUT_VARIABLE HG_REVISION
-#  OUTPUT_STRIP_TRAILING_WHITESPACE)
-
 SET(PROJECT_NAME "LEMON")
-SET(PROJECT_VERSION_MAJOR "0")
-SET(PROJECT_VERSION_MINOR "99")
-SET(PROJECT_VERSION_PATCH "0")
-SET(PROJECT_VERSION
-  "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}")
+SET(PROJECT_VERSION "hg-tip" CACHE STRING "The version string.")
 
 PROJECT(${PROJECT_NAME})
 
@@ -39,15 +30,12 @@
     "LEMON - Library of Efficient Models and Optimization in Networks")
   SET(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/LICENSE")
 
-  SET(CPACK_PACKAGE_VERSION_MAJOR ${PROJECT_VERSION_MAJOR})
-  SET(CPACK_PACKAGE_VERSION_MINOR ${PROJECT_VERSION_MINOR})
-  SET(CPACK_PACKAGE_VERSION_PATCH ${PROJECT_VERSION_PATCH})
   SET(CPACK_PACKAGE_VERSION ${PROJECT_VERSION})
 
   SET(CPACK_PACKAGE_INSTALL_DIRECTORY
-    "${PROJECT_NAME} ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}")
+    "${PROJECT_NAME} ${PROJECT_VERSION}")
   SET(CPACK_PACKAGE_INSTALL_REGISTRY_KEY
-    "${PROJECT_NAME} ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}")
+    "${PROJECT_NAME} ${PROJECT_VERSION}")
 
   # Variables to generate a component-based installer.
   #SET(CPACK_COMPONENTS_ALL headers library html_documentation)
diff -r 931190050520 -r 6307bbbf285b NEWS
--- a/NEWS	Mon Sep 22 15:33:23 2008 +0200
+++ b/NEWS	Tue Sep 23 18:42:49 2008 +0200
@@ -0,0 +1,49 @@
+20XX-XX-XX Version 1.0 released
+
+	This is the first stable release of LEMON. Compared to the 0.x
+	release series, it features a considerably smaller but more
+	matured set of tools. The API has also completely revised and
+	changed in several places.
+
+	* The major name changes compared to the 0.x series
+          * Graph -> Digraph, UGraph -> Graph
+          * Edge -> Arc, UEdge -> Edge
+	  * source(UEdge)/target(UEdge) -> u(Edge)/v(Edge)
+	* Other improvements
+	  * Better documentation
+	  * Reviewed and cleaned up codebase
+	  * CMake based build system (along with the autotools based one)
+	* Contents of the library (ported from 0.x)
+	  * Algorithms
+       	    * breadth-first search (bfs.h)
+       	    * depth-first search (dfs.h)
+       	    * Dijkstra's algorithm (dijkstra.h)
+       	    * Kruskal's algorithm (kruskal.h)
+    	  * Data structures
+       	    * graph data structures (list_graph.h, smart_graph.h)
+       	    * path data structures (path.h)
+       	    * binary heap data structure (bin_heap.h)
+       	    * union-find data structures (unionfind.h)
+       	    * miscellaneous property maps (maps.h)
+       	    * two dimensional vector and bounding box (dim2.h)
+          * Concepts
+       	    * graph structure concepts (concepts/digraph.h, concepts/graph.h,
+              concepts/graph_components.h)
+       	    * concepts for other structures (concepts/heap.h, concepts/maps.h,
+	      concepts/path.h)
+    	  * Tools
+       	    * Mersenne twister random number generator (random.h)
+       	    * tools for measuring cpu and wall clock time (time_measure.h)
+       	    * tools for counting steps and events (counter.h)
+       	    * tool for parsing command line arguments (arg_parser.h)
+       	    * tool for visualizing graphs (graph_to_eps.h)
+       	    * tools for reading and writing data in LEMON Graph Format
+              (lgf_reader.h, lgf_writer.h)
+            * tools to handle the anomalies of calculations with
+	      floating point numbers (tolerance.h)
+            * tools to manage RGB colors (color.h)
+    	  * Infrastructure
+       	    * extended assertion handling (assert.h)
+       	    * exception classes and error handling (error.h)
+      	    * concept checking (concept_check.h)
+       	    * commonly used mathematical constants (math.h)
diff -r 931190050520 -r 6307bbbf285b configure.ac
--- a/configure.ac	Mon Sep 22 15:33:23 2008 +0200
+++ b/configure.ac	Tue Sep 23 18:42:49 2008 +0200
@@ -1,9 +1,15 @@
 dnl Process this file with autoconf to produce a configure script.
 
 dnl Version information.
-m4_define([lemon_version_number], [])
+m4_define([lemon_version_number],
+	[m4_normalize(esyscmd([echo ${LEMON_VERSION}]))])
+dnl m4_define([lemon_version_number], [])
+m4_define([lemon_hg_path], [m4_normalize(esyscmd([./scripts/chg-len.py]))])
 m4_define([lemon_hg_revision], [m4_normalize(esyscmd([hg id -i]))])
-m4_define([lemon_version], [ifelse(lemon_version_number(), [], [lemon_hg_revision()], [lemon_version_number()])])
+m4_define([lemon_version], [ifelse(lemon_version_number(),
+			   [],
+			   [lemon_hg_path().lemon_hg_revision()],
+			   [lemon_version_number()])])
 
 AC_PREREQ([2.59])
 AC_INIT([LEMON], [lemon_version()], [lemon-user at lemon.cs.elte.hu], [lemon])
diff -r 931190050520 -r 6307bbbf285b doc/Makefile.am
--- a/doc/Makefile.am	Mon Sep 22 15:33:23 2008 +0200
+++ b/doc/Makefile.am	Tue Sep 23 18:42:49 2008 +0200
@@ -6,6 +6,7 @@
 	doc/lgf.dox \
 	doc/license.dox \
 	doc/mainpage.dox \
+	doc/named-param.dox \
 	doc/namespaces.dox \
 	doc/html \
 	doc/CMakeLists.txt
diff -r 931190050520 -r 6307bbbf285b doc/named-param.dox
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/doc/named-param.dox	Tue Sep 23 18:42:49 2008 +0200
@@ -0,0 +1,119 @@
+/* -*- mode: C++; indent-tabs-mode: nil; -*-
+ *
+ * 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.
+ *
+ */
+
+/*!
+
+\page named-param Named Parameters
+
+\section named-func-param Named Function Parameters
+
+Several modern languages provide a convenient way to refer the
+function parameters by name also when you call the function. It is
+especially comfortable in case of a function having tons of parameters
+with natural default values. Sadly, C++ lack this amenity.
+
+However, with a crafty trick and with some little
+inconvenience, it is possible to emulate is.
+The example below shows how to do it.
+
+\code
+class namedFn
+{
+  int _id;
+  double _val;
+  int _dim;
+
+  public:
+  namedFn() : _id(0), _val(1), _dim(2) {}
+  namedFn& id(int p)     { _id  = p ; return *this; }
+  namedFn& val(double p) { _val = p ; return *this; }
+  namedFn& dim(int p)    { _dim = p ; return *this; }
+
+  run() {
+    std::cout << "Here comes the function itself\n" <<
+              << "With parameters "
+              << _id << ", " << _val << ", " << _dim << std::endl;
+  }
+};
+\endcode
+
+Then you can use it like this.
+
+\code
+namedFn().id(3).val(2).run();
+\endcode
+
+The trick is obvious, each "named parameter" changes one component of
+the underlying class, then gives back a reference to it. Finally,
+<tt>run()</tt> executes the algorithm itself.
+
+\note Although it is a class, namedFn is used pretty much like as it were
+a function. That it why we called it namedFn instead of \c NamedFn.
+
+\note In fact, the final <tt>.run()</tt> could be made unnecessary,
+because the algorithm could also be implemented in the destructor of
+\c namedFn instead. This however would make it impossible to implement
+functions with return values, and would also cause serious problems when
+implementing \ref named-templ-func-param "named template parameters".
+<b>Therefore, by convention, <tt>.run()</tt> must be used
+explicitly to execute a function having named parameters
+everywhere in LEMON.</b>
+
+\section named-templ-func-param Named Function Template Parameters
+
+A named parameter can also be a template function. The usage is
+exactly the same, but the implementation behind is a kind of black
+magic and they are the dirtiest part of the LEMON code.
+
+You will probably never need to know how it works, but if you really
+committed, have a look at \ref lemon/graph_to_eps.h for an example.
+
+\section traits-classes Traits Classes
+
+A similar game can also be played when defining classes. In this case
+the type of the class attributes can be changed. Initially we have to
+define a special class called <em>Traits Class</em> defining the
+default type of the attributes. Then the types of these attributes can
+be changed in the same way as described in the next section.
+
+See \ref lemon::DijkstraDefaultTraits for an
+example how a traits class implementation looks like.
+
+\section named-templ-param Named Class Template Parameters
+
+If we would like to change the type of an attribute in a class that
+was instantiated by using a traits class as a template parameter, and
+the class contains named parameters, we do not have to instantiate again
+the class with new traits class, but instead adaptor classes can
+be used as shown in the following example.
+
+\code
+Dijkstra<>::SetPredMap<NullMap<Node,Arc> >::Create
+\endcode
+
+It can also be used in conjunction with other named template
+parameters in arbitrary order.
+
+\code
+Dijkstra<>::SetDistMap<MyMap>::SetPredMap<NullMap<Node,Arc> >::Create
+\endcode
+
+The result will be an instantiated Dijkstra class, in which the
+DistMap and the PredMap is modified.
+
+*/
diff -r 931190050520 -r 6307bbbf285b lemon/arg_parser.h
--- a/lemon/arg_parser.h	Mon Sep 22 15:33:23 2008 +0200
+++ b/lemon/arg_parser.h	Tue Sep 23 18:42:49 2008 +0200
@@ -16,8 +16,8 @@
  *
  */
 
-#ifndef LEMON_ARG_PARSER
-#define LEMON_ARG_PARSER
+#ifndef LEMON_ARG_PARSER_H
+#define LEMON_ARG_PARSER_H
 
 #include <vector>
 #include <map>
@@ -382,4 +382,4 @@
   };
 }
 
-#endif // LEMON_ARG_PARSER
+#endif // LEMON_ARG_PARSER_H
diff -r 931190050520 -r 6307bbbf285b lemon/assert.h
--- a/lemon/assert.h	Mon Sep 22 15:33:23 2008 +0200
+++ b/lemon/assert.h	Tue Sep 23 18:42:49 2008 +0200
@@ -27,8 +27,9 @@
 
 namespace lemon {
 
-  inline void assert_fail_log(const char *file, int line, const char *function,
-                              const char *message, const char *assertion)
+  inline void assert_fail_abort(const char *file, int line,
+                                const char *function, const char* message,
+                                const char *assertion)
   {
     std::cerr << file << ":" << line << ": ";
     if (function)
@@ -37,13 +38,6 @@
     if (assertion)
       std::cerr << " (assertion '" << assertion << "' failed)";
     std::cerr << std::endl;
-  }
-
-  inline void assert_fail_abort(const char *file, int line,
-                                const char *function, const char* message,
-                                const char *assertion)
-  {
-    assert_fail_log(file, line, function, message, assertion);
     std::abort();
   }
 
@@ -63,17 +57,14 @@
 #endif // LEMON_ASSERT_H
 
 #undef LEMON_ASSERT



More information about the Lemon-commits mailing list