Index: AUTHORS
===================================================================
--- AUTHORS	(revision a80f4195d731fd366a976130725a3e131376108f)
+++ AUTHORS	(revision a80f4195d731fd366a976130725a3e131376108f)
@@ -0,0 +1,3 @@
+Tillmann Crueger	(crueger@ins.uni-bonn.de)
+Frederik Heber		(heber@ins.uni-bonn.de)
+Saskia Metzler		(metzler@ins.uni-bonn.de)
Index: COPYING
===================================================================
--- COPYING	(revision a80f4195d731fd366a976130725a3e131376108f)
+++ COPYING	(revision a80f4195d731fd366a976130725a3e131376108f)
@@ -0,0 +1,346 @@
+		    GNU GENERAL PUBLIC LICENSE
+		       Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.
+     51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+			    Preamble
+
+  The licenses for most software are designed to take away your
+freedom to share and change it.  By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users.  This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it.  (Some other Free Software Foundation software is covered by
+the GNU Library General Public License instead.)  You can apply it to
+your programs, too.
+
+  When we speak of free software, we are referring to freedom, not
+price.  Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+  To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+  For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have.  You must make sure that they, too, receive or can get the
+source code.  And you must show them these terms so they know their
+rights.
+
+  We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+  Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software.  If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+  Finally, any free program is threatened constantly by software
+patents.  We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary.  To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+  The precise terms and conditions for copying, distribution and
+modification follow.
+
+
+		    GNU GENERAL PUBLIC LICENSE
+   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+  0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License.  The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language.  (Hereinafter, translation is included without limitation in
+the term "modification".)  Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope.  The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+  1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+  2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+    a) You must cause the modified files to carry prominent notices
+    stating that you changed the files and the date of any change.
+
+    b) You must cause any work that you distribute or publish, that in
+    whole or in part contains or is derived from the Program or any
+    part thereof, to be licensed as a whole at no charge to all third
+    parties under the terms of this License.
+
+    c) If the modified program normally reads commands interactively
+    when run, you must cause it, when started running for such
+    interactive use in the most ordinary way, to print or display an
+    announcement including an appropriate copyright notice and a
+    notice that there is no warranty (or else, saying that you provide
+    a warranty) and that users may redistribute the program under
+    these conditions, and telling the user how to view a copy of this
+    License.  (Exception: if the Program itself is interactive but
+    does not normally print such an announcement, your work based on
+    the Program is not required to print an announcement.)
+
+
+These requirements apply to the modified work as a whole.  If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works.  But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+  3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+    a) Accompany it with the complete corresponding machine-readable
+    source code, which must be distributed under the terms of Sections
+    1 and 2 above on a medium customarily used for software interchange; or,
+
+    b) Accompany it with a written offer, valid for at least three
+    years, to give any third party, for a charge no more than your
+    cost of physically performing source distribution, a complete
+    machine-readable copy of the corresponding source code, to be
+    distributed under the terms of Sections 1 and 2 above on a medium
+    customarily used for software interchange; or,
+
+    c) Accompany it with the information you received as to the offer
+    to distribute corresponding source code.  (This alternative is
+    allowed only for noncommercial distribution and only if you
+    received the program in object code or executable form with such
+    an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it.  For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable.  However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+
+  4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License.  Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+  5. You are not required to accept this License, since you have not
+signed it.  However, nothing else grants you permission to modify or
+distribute the Program or its derivative works.  These actions are
+prohibited by law if you do not accept this License.  Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+  6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions.  You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+  7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License.  If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all.  For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices.  Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+
+  8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded.  In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+  9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time.  Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number.  If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation.  If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+  10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission.  For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this.  Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+			    NO WARRANTY
+
+  11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+  12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
+
+		     END OF TERMS AND CONDITIONS
+
+
+	    How to Apply These Terms to Your New Programs
+
+  If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+  To do so, attach the following notices to the program.  It is safest
+to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+    MoleCuilder - to create and alter molecular systems
+    Copyright (C) 2010  Frederik Heber
+
+    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.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
+
+    MoleCuilder version ??, Copyright (C) 2010  Frederik Heber
+    MoleCuilder comes with ABSOLUTELY NO WARRANTY; for details type 
+    `molecuilder --help-warranty'.
+    This is free software, and you are welcome to redistribute it
+    under certain conditions; type `molecuilder --help-redistribute' 
+    for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License.  Of course, the commands you use may
+be called something other than `show w' and `show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary.  Here is a sample; alter the names:
+
+  University of Bonn, hereby disclaims all copyright interest in the program
+  `MoleCuilder' (which creates molecular systems) written by Frederik Heber.
+
+  Frederik Heber, 17 Aug 2010
+
+This General Public License does not permit incorporating your program into
+proprietary programs.  If your program is a subroutine library, you may
+consider it more useful to permit linking proprietary applications with the
+library.  If this is what you want to do, use the GNU Library General
+Public License instead of this License.
Index: CodePatterns.pc.in
===================================================================
--- CodePatterns.pc.in	(revision a80f4195d731fd366a976130725a3e131376108f)
+++ CodePatterns.pc.in	(revision a80f4195d731fd366a976130725a3e131376108f)
@@ -0,0 +1,11 @@
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+libdir=@libdir@
+includedir=@includedir@
+
+Name: @PACKAGE_NAME@
+Description: CodePatterns - various design schemes and helpers to initial application development
+Version: @PACKAGE_VERSION@
+URL: @PACKAGE_URL@
+Libs: -L${libdir} -lCodePatterns-@EXAMPLE_API_VERSION@
+Cflags: -I${includedir}/CodPatterns-@EXAMPLE_API_VERSION@
Index: INSTALL
===================================================================
--- INSTALL	(revision a80f4195d731fd366a976130725a3e131376108f)
+++ INSTALL	(revision a80f4195d731fd366a976130725a3e131376108f)
@@ -0,0 +1,365 @@
+Installation Instructions
+*************************
+
+Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005,
+2006, 2007, 2008, 2009 Free Software Foundation, Inc.
+
+   Copying and distribution of this file, with or without modification,
+are permitted in any medium without royalty provided the copyright
+notice and this notice are preserved.  This file is offered as-is,
+without warranty of any kind.
+
+Basic Installation
+==================
+
+   Briefly, the shell commands `./configure; make; make install' should
+configure, build, and install this package.  The following
+more-detailed instructions are generic; see the `README' file for
+instructions specific to this package.  Some packages provide this
+`INSTALL' file but do not implement all of the features documented
+below.  The lack of an optional feature in a given package is not
+necessarily a bug.  More recommendations for GNU packages can be found
+in *note Makefile Conventions: (standards)Makefile Conventions.
+
+   The `configure' shell script attempts to guess correct values for
+various system-dependent variables used during compilation.  It uses
+those values to create a `Makefile' in each directory of the package.
+It may also create one or more `.h' files containing system-dependent
+definitions.  Finally, it creates a shell script `config.status' that
+you can run in the future to recreate the current configuration, and a
+file `config.log' containing compiler output (useful mainly for
+debugging `configure').
+
+   It can also use an optional file (typically called `config.cache'
+and enabled with `--cache-file=config.cache' or simply `-C') that saves
+the results of its tests to speed up reconfiguring.  Caching is
+disabled by default to prevent problems with accidental use of stale
+cache files.
+
+   If you need to do unusual things to compile the package, please try
+to figure out how `configure' could check whether to do them, and mail
+diffs or instructions to the address given in the `README' so they can
+be considered for the next release.  If you are using the cache, and at
+some point `config.cache' contains results you don't want to keep, you
+may remove or edit it.
+
+   The file `configure.ac' (or `configure.in') is used to create
+`configure' by a program called `autoconf'.  You need `configure.ac' if
+you want to change it or regenerate `configure' using a newer version
+of `autoconf'.
+
+   The simplest way to compile this package is:
+
+  1. `cd' to the directory containing the package's source code and type
+     `./configure' to configure the package for your system.
+
+     Running `configure' might take a while.  While running, it prints
+     some messages telling which features it is checking for.
+
+  2. Type `make' to compile the package.
+
+  3. Optionally, type `make check' to run any self-tests that come with
+     the package, generally using the just-built uninstalled binaries.
+
+  4. Type `make install' to install the programs and any data files and
+     documentation.  When installing into a prefix owned by root, it is
+     recommended that the package be configured and built as a regular
+     user, and only the `make install' phase executed with root
+     privileges.
+
+  5. Optionally, type `make installcheck' to repeat any self-tests, but
+     this time using the binaries in their final installed location.
+     This target does not install anything.  Running this target as a
+     regular user, particularly if the prior `make install' required
+     root privileges, verifies that the installation completed
+     correctly.
+
+  6. You can remove the program binaries and object files from the
+     source code directory by typing `make clean'.  To also remove the
+     files that `configure' created (so you can compile the package for
+     a different kind of computer), type `make distclean'.  There is
+     also a `make maintainer-clean' target, but that is intended mainly
+     for the package's developers.  If you use it, you may have to get
+     all sorts of other programs in order to regenerate files that came
+     with the distribution.
+
+  7. Often, you can also type `make uninstall' to remove the installed
+     files again.  In practice, not all packages have tested that
+     uninstallation works correctly, even though it is required by the
+     GNU Coding Standards.
+
+  8. Some packages, particularly those that use Automake, provide `make
+     distcheck', which can by used by developers to test that all other
+     targets like `make install' and `make uninstall' work correctly.
+     This target is generally not run by end users.
+
+Compilers and Options
+=====================
+
+   Some systems require unusual options for compilation or linking that
+the `configure' script does not know about.  Run `./configure --help'
+for details on some of the pertinent environment variables.
+
+   You can give `configure' initial values for configuration parameters
+by setting variables in the command line or in the environment.  Here
+is an example:
+
+     ./configure CC=c99 CFLAGS=-g LIBS=-lposix
+
+   *Note Defining Variables::, for more details.
+
+Compiling For Multiple Architectures
+====================================
+
+   You can compile the package for more than one kind of computer at the
+same time, by placing the object files for each architecture in their
+own directory.  To do this, you can use GNU `make'.  `cd' to the
+directory where you want the object files and executables to go and run
+the `configure' script.  `configure' automatically checks for the
+source code in the directory that `configure' is in and in `..'.  This
+is known as a "VPATH" build.
+
+   With a non-GNU `make', it is safer to compile the package for one
+architecture at a time in the source code directory.  After you have
+installed the package for one architecture, use `make distclean' before
+reconfiguring for another architecture.
+
+   On MacOS X 10.5 and later systems, you can create libraries and
+executables that work on multiple system types--known as "fat" or
+"universal" binaries--by specifying multiple `-arch' options to the
+compiler but only a single `-arch' option to the preprocessor.  Like
+this:
+
+     ./configure CC="gcc -arch i386 -arch x86_64 -arch ppc -arch ppc64" \
+                 CXX="g++ -arch i386 -arch x86_64 -arch ppc -arch ppc64" \
+                 CPP="gcc -E" CXXCPP="g++ -E"
+
+   This is not guaranteed to produce working output in all cases, you
+may have to build one architecture at a time and combine the results
+using the `lipo' tool if you have problems.
+
+Installation Names
+==================
+
+   By default, `make install' installs the package's commands under
+`/usr/local/bin', include files under `/usr/local/include', etc.  You
+can specify an installation prefix other than `/usr/local' by giving
+`configure' the option `--prefix=PREFIX', where PREFIX must be an
+absolute file name.
+
+   You can specify separate installation prefixes for
+architecture-specific files and architecture-independent files.  If you
+pass the option `--exec-prefix=PREFIX' to `configure', the package uses
+PREFIX as the prefix for installing programs and libraries.
+Documentation and other data files still use the regular prefix.
+
+   In addition, if you use an unusual directory layout you can give
+options like `--bindir=DIR' to specify different values for particular
+kinds of files.  Run `configure --help' for a list of the directories
+you can set and what kinds of files go in them.  In general, the
+default for these options is expressed in terms of `${prefix}', so that
+specifying just `--prefix' will affect all of the other directory
+specifications that were not explicitly provided.
+
+   The most portable way to affect installation locations is to pass the
+correct locations to `configure'; however, many packages provide one or
+both of the following shortcuts of passing variable assignments to the
+`make install' command line to change installation locations without
+having to reconfigure or recompile.
+
+   The first method involves providing an override variable for each
+affected directory.  For example, `make install
+prefix=/alternate/directory' will choose an alternate location for all
+directory configuration variables that were expressed in terms of
+`${prefix}'.  Any directories that were specified during `configure',
+but not in terms of `${prefix}', must each be overridden at install
+time for the entire installation to be relocated.  The approach of
+makefile variable overrides for each directory variable is required by
+the GNU Coding Standards, and ideally causes no recompilation.
+However, some platforms have known limitations with the semantics of
+shared libraries that end up requiring recompilation when using this
+method, particularly noticeable in packages that use GNU Libtool.
+
+   The second method involves providing the `DESTDIR' variable.  For
+example, `make install DESTDIR=/alternate/directory' will prepend
+`/alternate/directory' before all installation names.  The approach of
+`DESTDIR' overrides is not required by the GNU Coding Standards, and
+does not work on platforms that have drive letters.  On the other hand,
+it does better at avoiding recompilation issues, and works well even
+when some directory options were not specified in terms of `${prefix}'
+at `configure' time.
+
+Optional Features
+=================
+
+   If the package supports it, you can cause programs to be installed
+with an extra prefix or suffix on their names by giving `configure' the
+option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
+
+   Some packages pay attention to `--enable-FEATURE' options to
+`configure', where FEATURE indicates an optional part of the package.
+They may also pay attention to `--with-PACKAGE' options, where PACKAGE
+is something like `gnu-as' or `x' (for the X Window System).  The
+`README' should mention any `--enable-' and `--with-' options that the
+package recognizes.
+
+   For packages that use the X Window System, `configure' can usually
+find the X include and library files automatically, but if it doesn't,
+you can use the `configure' options `--x-includes=DIR' and
+`--x-libraries=DIR' to specify their locations.
+
+   Some packages offer the ability to configure how verbose the
+execution of `make' will be.  For these packages, running `./configure
+--enable-silent-rules' sets the default to minimal output, which can be
+overridden with `make V=1'; while running `./configure
+--disable-silent-rules' sets the default to verbose, which can be
+overridden with `make V=0'.
+
+Particular systems
+==================
+
+   On HP-UX, the default C compiler is not ANSI C compatible.  If GNU
+CC is not installed, it is recommended to use the following options in
+order to use an ANSI C compiler:
+
+     ./configure CC="cc -Ae -D_XOPEN_SOURCE=500"
+
+and if that doesn't work, install pre-built binaries of GCC for HP-UX.
+
+   On OSF/1 a.k.a. Tru64, some versions of the default C compiler cannot
+parse its `<wchar.h>' header file.  The option `-nodtk' can be used as
+a workaround.  If GNU CC is not installed, it is therefore recommended
+to try
+
+     ./configure CC="cc"
+
+and if that doesn't work, try
+
+     ./configure CC="cc -nodtk"
+
+   On Solaris, don't put `/usr/ucb' early in your `PATH'.  This
+directory contains several dysfunctional programs; working variants of
+these programs are available in `/usr/bin'.  So, if you need `/usr/ucb'
+in your `PATH', put it _after_ `/usr/bin'.
+
+   On Haiku, software installed for all users goes in `/boot/common',
+not `/usr/local'.  It is recommended to use the following options:
+
+     ./configure --prefix=/boot/common
+
+Specifying the System Type
+==========================
+
+   There may be some features `configure' cannot figure out
+automatically, but needs to determine by the type of machine the package
+will run on.  Usually, assuming the package is built to be run on the
+_same_ architectures, `configure' can figure that out, but if it prints
+a message saying it cannot guess the machine type, give it the
+`--build=TYPE' option.  TYPE can either be a short name for the system
+type, such as `sun4', or a canonical name which has the form:
+
+     CPU-COMPANY-SYSTEM
+
+where SYSTEM can have one of these forms:
+
+     OS
+     KERNEL-OS
+
+   See the file `config.sub' for the possible values of each field.  If
+`config.sub' isn't included in this package, then this package doesn't
+need to know the machine type.
+
+   If you are _building_ compiler tools for cross-compiling, you should
+use the option `--target=TYPE' to select the type of system they will
+produce code for.
+
+   If you want to _use_ a cross compiler, that generates code for a
+platform different from the build platform, you should specify the
+"host" platform (i.e., that on which the generated programs will
+eventually be run) with `--host=TYPE'.
+
+Sharing Defaults
+================
+
+   If you want to set default values for `configure' scripts to share,
+you can create a site shell script called `config.site' that gives
+default values for variables like `CC', `cache_file', and `prefix'.
+`configure' looks for `PREFIX/share/config.site' if it exists, then
+`PREFIX/etc/config.site' if it exists.  Or, you can set the
+`CONFIG_SITE' environment variable to the location of the site script.
+A warning: not all `configure' scripts look for a site script.
+
+Defining Variables
+==================
+
+   Variables not defined in a site shell script can be set in the
+environment passed to `configure'.  However, some packages may run
+configure again during the build, and the customized values of these
+variables may be lost.  In order to avoid this problem, you should set
+them in the `configure' command line, using `VAR=value'.  For example:
+
+     ./configure CC=/usr/local2/bin/gcc
+
+causes the specified `gcc' to be used as the C compiler (unless it is
+overridden in the site shell script).
+
+Unfortunately, this technique does not work for `CONFIG_SHELL' due to
+an Autoconf bug.  Until the bug is fixed you can use this workaround:
+
+     CONFIG_SHELL=/bin/bash /bin/bash ./configure CONFIG_SHELL=/bin/bash
+
+`configure' Invocation
+======================
+
+   `configure' recognizes the following options to control how it
+operates.
+
+`--help'
+`-h'
+     Print a summary of all of the options to `configure', and exit.
+
+`--help=short'
+`--help=recursive'
+     Print a summary of the options unique to this package's
+     `configure', and exit.  The `short' variant lists options used
+     only in the top level, while the `recursive' variant lists options
+     also present in any nested packages.
+
+`--version'
+`-V'
+     Print the version of Autoconf used to generate the `configure'
+     script, and exit.
+
+`--cache-file=FILE'
+     Enable the cache: use and save the results of the tests in FILE,
+     traditionally `config.cache'.  FILE defaults to `/dev/null' to
+     disable caching.
+
+`--config-cache'
+`-C'
+     Alias for `--cache-file=config.cache'.
+
+`--quiet'
+`--silent'
+`-q'
+     Do not print messages saying which checks are being made.  To
+     suppress all normal output, redirect it to `/dev/null' (any error
+     messages will still be shown).
+
+`--srcdir=DIR'
+     Look for the package's source code in directory DIR.  Usually
+     `configure' can determine that directory automatically.
+
+`--prefix=DIR'
+     Use DIR as the installation prefix.  *note Installation Names::
+     for more details, including other options available for fine-tuning
+     the installation locations.
+
+`--no-create'
+`-n'
+     Run the configure checks, but stop before creating any output
+     files.
+
+`configure' also accepts some other, not widely useful, options.  Run
+`configure --help' for more details.
+
Index: Makefile.am
===================================================================
--- Makefile.am	(revision a80f4195d731fd366a976130725a3e131376108f)
+++ Makefile.am	(revision a80f4195d731fd366a976130725a3e131376108f)
@@ -0,0 +1,11 @@
+ACLOCAL_AMFLAGS = -I m4
+SUBDIRS = src src/unittests doc
+
+AUTOMAKE_OPTIONS = subdir-objects
+
+EXTRA_DIST = bootstrap
+
+.PHONY: doc
+doc:
+	cd doc && make doxygen-docs
+	
Index: NEWS
===================================================================
--- NEWS	(revision a80f4195d731fd366a976130725a3e131376108f)
+++ NEWS	(revision a80f4195d731fd366a976130725a3e131376108f)
@@ -0,0 +1,3 @@
+v0.0.1
+------
+2010/12/20 extracted files from MoleCuilder.
Index: README
===================================================================
--- README	(revision a80f4195d731fd366a976130725a3e131376108f)
+++ README	(revision a80f4195d731fd366a976130725a3e131376108f)
@@ -0,0 +1,27 @@
+# Project: CodePatterns
+#
+# crueger@ins.uni-bonn.de, heber@ins.uni-bonn.de
+
+	CodePatterns
+
+...is a set of prefactured design schemes and tiny helpers that make lots of
+the day-to-day stuff easier such as
+ * Cachable, Observer, Registry, Singleton
+ * MemDebug, (better) Asserts, Logger
+It is intended to be used to create higher-level object-oriented code right
+from the scratch. The more object-oriented, structured code once writes, the
+more one tends to write before any output comes out of it. These patterns are
+meant to ease this pain a little by supplying the programmer the developer
+with lots of tiny structures that he may introduce into his code right away
+with little effort but great use.
+
+
+INSTALLATION NOTES
+==================
+
+The following packages are needed
+* Boost 1.4 or newer
+
+LINKS
+=====
+[1] http://www.ins.uni-bonn.de/
Index: TestRunnerClient.cpp
===================================================================
--- TestRunnerClient.cpp	(revision a80f4195d731fd366a976130725a3e131376108f)
+++ TestRunnerClient.cpp	(revision a80f4195d731fd366a976130725a3e131376108f)
@@ -0,0 +1,542 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Gerhard Leonhartsberger.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *******************************************************************************/
+
+#include "TestRunnerClient.h"
+
+#ifdef CPPUNIT_MAIN
+
+#include "cppunit/TestResultCollector.h"
+#include "cppunit/XmlOutputter.h"
+#include "cppunit/TestSuite.h"
+#include "cppunit/TestResult.h"
+#include "cppunit/TestFailure.h"
+#include "cppunit/SourceLine.h"
+#include "cppunit/Exception.h"
+#include "cppunit/extensions/TestFactoryRegistry.h"
+#include "cppunit/extensions/TestDecorator.h"
+#include "cppunit/ui/text/TestRunner.h"
+
+#include <iostream>
+#include <sstream>
+#include <typeinfo>
+#include <vector>
+#include <cstring>
+
+#include <errno.h>
+#include <unistd.h>
+#include <sys/time.h>
+#include <stdlib.h>
+
+
+#ifdef _WIN32 // Bugzilla 40710
+#include <windows.h>
+#include <winbase.h>
+#include <winsock.h>
+#else
+#include <netinet/in.h>
+#include <sys/socket.h>
+#include <arpa/inet.h>
+#include <netdb.h>
+#endif
+
+enum { MAX_HOSTNAME_SIZE=255 };
+
+/*
+ * CppUnitServer protocol constants
+ */
+static const std::string TRACE_START = "%TRACES ";
+static const std::string TRACE_END = "%TRACEE ";
+static const std::string TEST_RUN_START = "%TESTC  ";
+static const std::string TEST_START = "%TESTS  ";
+static const std::string TEST_END = "%TESTE  ";
+static const std::string TEST_ERROR = "%ERROR  ";
+static const std::string TEST_FAILED = "%FAILED ";
+static const std::string TEST_RUN_END = "%RUNTIME";
+static const std::string TEST_STOPPED = "%TSTSTP ";
+static const std::string TEST_TREE = "%TSTTREE";
+
+TestRunnerClient::TestRunnerClient()
+{
+	fTestResult = 0;
+	fClientSocket = -1;
+	fPort = 0;
+	fKeepAlive = 0;
+	fDebugMode = 0;
+
+	fHost = (char *) malloc(MAX_HOSTNAME_SIZE);
+	strcpy(fHost, "");
+}
+
+TestRunnerClient::~TestRunnerClient() {
+
+	if (fHost != NULL) {
+		free(fHost);
+	}
+}
+
+int TestRunnerClient::Run()
+{
+	if (fDebugMode)
+	{
+		std::cerr << "TestRunnerClient: Starting client." << std::endl;
+	}
+
+	if (Connect() == -1) {
+		return -1;
+	}
+
+	InstallListeners();
+
+	RunTests();
+
+	UninstallListeners();
+
+	if(fTestResult != NULL)
+	{
+		fTestResult->stop();
+		fTestResult= NULL;
+	}
+
+	ShutDown();
+
+	return 0;
+}
+
+void TestRunnerClient::Init(int n, char *args[])
+{
+	ParseCommandLine(n, args);
+	DefineHostName();
+}
+
+void TestRunnerClient::ParseCommandLine(int n, char *args[])
+{
+	// parse all arguments passed by args
+	for(int i = 0; i < n; i++)
+	{
+		std::string arg(args[i]);
+
+		// port option
+		std::string portOption("-port=");
+		int pos = arg.find(portOption);
+		if(pos> -1)
+		{
+			std::string v = arg.substr(pos + portOption.length(), arg.length());
+			fPort = atoi(v.c_str());
+		}
+
+		// debug option
+		std::string debugOption("-debug");
+		pos = arg.find(debugOption);
+		if(pos> - 1)
+		{
+			fDebugMode = 1;
+		}
+	}
+}
+
+void TestRunnerClient::DefineHostName()
+{
+	// set fHost to hostname or localhost
+	int ret = gethostname(fHost, MAX_HOSTNAME_SIZE);
+	if (ret == -1)
+	{
+		strcpy(fHost, "localhost");
+	}
+}
+
+int TestRunnerClient::Connect()
+{
+
+#ifdef _WIN32 // Bugzilla 40710
+	if (fDebugMode)
+	{
+		std::cerr << "TestRunnerClient: Starting Windows Sockets WSAStartup()." << std:endl;
+	}
+
+	// start up Windows Sockets
+	WSADATA WSAData;
+	int result = WSAStartup (MAKEWORD(1, 1), &WSAData);
+	if (result != NO_ERROR)
+	{
+		std::cerr << "TestRunnerClient: WSAStartup() failed! Error code: " << result << std::endl;
+		return -1;
+	}
+#endif
+
+	if (fDebugMode)
+	{
+		std::cerr << "TestRunnerClient: Trying to connect to " << fHost << ":" << fPort << std::endl;
+	}
+
+	fClientSocket = socket(AF_INET, SOCK_STREAM, 0);
+	if (fClientSocket == -1)
+	{
+		std::cerr << "TestRunnerClient: Socket creation failed! error code: " << fClientSocket << std::endl;
+		return -1;
+	}
+
+	struct hostent *host = gethostbyname(fHost);
+	if (host == NULL)
+	{
+		std::cerr << "TestRunnerClient: Cannot find host address for " << fHost << "." << std::endl;
+		fClientSocket = -1;
+		return -1;
+	}
+
+	struct sockaddr_in name;
+	memset((void *)&name, 0, sizeof(struct sockaddr_in));
+	name.sin_family = AF_INET;
+	name.sin_port = htons(fPort);
+
+	memcpy(&name.sin_addr, host->h_addr, host->h_length);
+
+	if (fDebugMode) {
+		std::cerr << "TestRunnerClient: Waiting for the JVM to listen ... (trying 3 times)" << std::endl;
+	}
+
+	int ret = -1;
+	int j = 0;
+	while ((j < 3) && (ret == -1))
+	{
+		ret = ::connect(fClientSocket, (struct sockaddr *) &name, sizeof(struct sockaddr_in));
+		if (ret == -1)
+		{
+			if (fDebugMode) {
+				std::cerr << "TestRunnerClient: Connection request, waiting 1 second. "
+				<< ((j-3)*-1) << " times left." << std::endl;
+			}
+			PrivateSleep(1000);
+			j++;
+		}
+	}
+	if (ret == -1)
+	{
+		std::cerr << "TestRunnerClient: No connection established. Error code: " << errno << std::endl;
+		fClientSocket = -1;
+		return -1;
+	}
+
+	if (fDebugMode) {
+		std::cerr << "TestRunnerClient: Connection established." << std::endl;
+	}
+	return 0;
+}
+
+void TestRunnerClient::InstallListeners()
+{
+	fTestResult = new CppUnit::TestResult();
+	fTestResult->addListener(this);
+}
+
+void TestRunnerClient::UninstallListeners()
+{
+	fTestResult->removeListener(this);
+}
+
+void TestRunnerClient::RunTests()
+{
+
+	CppUnit::TestFactoryRegistry &registry = CppUnit::TestFactoryRegistry::getRegistry();
+	CppUnit::Test *suite = registry.makeTest();
+	int count = suite->countTestCases();
+	NotifyTestRunStarted(count);
+
+	if (count == 0)
+	{
+		NotifyTestRunEnded(0);
+	}
+
+	long startTime = CurrentTimeMillis();
+	if (fDebugMode)
+	{
+		std::cerr <<"TestRunnerClient: Start sending test case tree ..." << std::endl;
+	}
+
+	SendTestTree(suite);
+
+	int elapsedTime = CurrentTimeMillis() - startTime;
+	if (fDebugMode) {
+		std::cerr << "TestRunnerClient: Done sending test case tree. Elapsed time is "
+		<< elapsedTime << "ms." << std::endl;
+	}
+
+	long testStartTime = CurrentTimeMillis();
+	if (fDebugMode) {
+		std::cerr << "TestRunnerClient: Test start time is " << testStartTime
+		<< "ms." << std::endl;
+	}
+
+	suite->run(fTestResult);
+
+	if (fTestResult == NULL || fTestResult->shouldStop())
+	{
+		NotifyTestRunStopped(CurrentTimeMillis() - testStartTime);
+	}
+	else
+	{
+		NotifyTestRunEnded(CurrentTimeMillis() - testStartTime);
+	}
+}
+
+void TestRunnerClient::ShutDown()
+{
+	if (fClientSocket != -1)
+	{
+		if (fDebugMode) {
+			std::cerr << "TestRunnerClient: Closing connection to CppUnit sever at "
+			<< fHost << ":" << fPort << std::endl;
+		}
+
+#ifdef _WIN32 // Bugzilla 40710
+		// TODO: std:err output for error return codes
+		closesocket(fClientSocket);
+		WSACleanup();
+#else
+		int result = close(fClientSocket);
+		if (result != 0)
+		{
+			std::cerr << "TestRunnerClient: Close connection error: " << errno << std::endl;
+		}
+#endif
+
+		fClientSocket = -1;
+	}
+}
+
+void TestRunnerClient::Stop()
+{
+	if (fTestResult != NULL)
+	{
+		fTestResult->stop();
+	}
+}
+
+void TestRunnerClient::SendTestTree(CppUnit::Test *test)
+{
+	if (typeid(*test) == typeid(CppUnit::TestDecorator))
+	{
+		class TmpClass : public CppUnit::TestDecorator {
+
+		public:
+			TmpClass(Test *t):CppUnit::TestDecorator(t)
+			{
+				// nothing to do
+			}
+
+			~TmpClass() // Bugzilla 39894
+			{
+				// nothing to do
+			}
+
+			CppUnit::Test *getTest()
+			{
+				return m_test;
+			}
+		};
+
+		TmpClass *t = (TmpClass *)test;
+		SendTestTree(t->getTest());
+	}
+	else if (typeid(*test) == typeid(CppUnit::TestSuite))
+	{
+		CppUnit::TestSuite *suite = (CppUnit::TestSuite *)test;
+		const std::vector<CppUnit::Test *> &x = suite->getTests();
+
+		std::ostringstream os;
+		os << suite->getName() << ",true," << x.size();
+		NotifyTestTreeEntry(os.str());
+
+		for(unsigned int i=0; i < x.size(); i++)
+		{
+			SendTestTree(x[i]);
+		}
+	}
+	else
+	{
+		std::ostringstream os;
+		os << test->getName() << ",false," << test->countTestCases();
+		NotifyTestTreeEntry(os.str());
+	}
+}
+
+void TestRunnerClient::SendMessage(std::string msg)
+{
+	if (fClientSocket == -1)
+	{
+		return;
+	}
+
+#ifdef _WIN32 // Bugzilla 40710
+	send (fClientSocket, msg.c_str(), msg.length(), 0);
+	send (fClientSocket, "\n", 1, 0);
+#else
+	write(fClientSocket, msg.c_str(), msg.length());
+	write(fClientSocket, "\n", 1);
+#endif
+
+	if (fDebugMode)
+	{
+		std::cerr << "TestRunnerClient: Sent message \"" << msg << "\""
+		<< std::endl;
+	}
+}
+
+void TestRunnerClient::NotifyTestRunStarted(int testCount)
+{
+	std::ostringstream os;
+	os << TEST_RUN_START << testCount;
+	SendMessage(os.str());
+}
+
+void TestRunnerClient::NotifyTestRunEnded(long elapsedTime)
+{
+	std::ostringstream os;
+	os << TEST_RUN_END << elapsedTime;
+	SendMessage(os.str());
+}
+
+void TestRunnerClient::NotifyTestRunStopped(long elapsedTime)
+{
+	std::ostringstream os;
+	os << TEST_STOPPED << elapsedTime;
+	SendMessage(os.str());
+}
+
+void TestRunnerClient::NotifyTestTreeEntry(std::string treeEntry)
+{
+	SendMessage(TEST_TREE + treeEntry);
+}
+
+void TestRunnerClient::NotifyTestStarted(std::string testName)
+{
+	SendMessage(TEST_START + testName);
+}
+
+void TestRunnerClient::NotifyTestEnded(std::string testName)
+{
+	SendMessage(TEST_END + testName);
+}
+
+void TestRunnerClient::NotifyTestFailed(std::string status, std::string testName, std::string trace)
+{
+	SendMessage(status + testName);
+	SendMessage(TRACE_START);
+	SendMessage(trace);
+	SendMessage(TRACE_END);
+}
+
+// From TestListener
+void TestRunnerClient::startTest(CppUnit::Test *test)
+{
+	NotifyTestStarted(test->getName());
+}
+
+// From TestListener
+void TestRunnerClient::addFailure(const CppUnit::TestFailure &failure)
+{
+	if(failure.isError())
+	{
+		NotifyTestFailed(TEST_ERROR,failure.failedTestName(),GetTrace(failure));
+	}
+	else
+	{
+		NotifyTestFailed(TEST_FAILED,failure.failedTestName(),GetTrace(failure));
+	}
+}
+
+// From TestListener
+void TestRunnerClient::endTest(CppUnit::Test *test)
+{
+	NotifyTestEnded(test->getName());
+}
+
+std::string TestRunnerClient::GetTrace(const CppUnit::TestFailure &failure)
+{
+	std::ostringstream os;
+
+	CppUnit::Exception *e=failure.thrownException();
+	if(e->sourceLine().lineNumber()!=-1)
+	{
+		os << "File " << e->sourceLine().fileName() << ":" << e->sourceLine().lineNumber() << "\n";
+	}
+	else
+	{
+		os << "File Unknown:1\n";
+	}
+	/* TODO: expected, actual value implementation
+	 if(typeid(*e)==typeid(CppUnit::NotEqualException))
+	 {
+	 CppUnit::NotEqualException *ne=(CppUnit::NotEqualException *)e;
+
+	 os << "Expected Value: " << ne->expectedValue() << "\n";
+	 os << "Actual Value: " << ne->expectedValue() << "\n";
+	 os << "Additional Message: " << ne->additionalMessage() << "\n";
+	 }
+	 else
+	 {
+	 End		*/
+	os << "Message: " << std::string(e->what()) << "\n";
+	/*		} */
+
+	return(os.str());
+}
+
+long TestRunnerClient::CurrentTimeMillis()
+{
+#ifdef _WIN32 // Bugzilla 40710
+	unsigned long long p;
+	__asm__ __volatile__ ("rdtsc" : "=A" (p));
+	return (unsigned long)p;
+#else
+	struct timeval tv;
+	gettimeofday(&tv, NULL);
+
+	return((long)(tv.tv_sec*1000) + (tv.tv_usec/1000));
+#endif
+}
+
+void TestRunnerClient::PrivateSleep(int millisecs)
+{
+	struct timeval delta;
+	delta.tv_sec = (millisecs * 1000L) / 1000000L;
+	delta.tv_usec = (millisecs * 1000L) % 1000000L;
+	select (0, NULL, NULL, NULL, &delta);
+}
+
+/*!
+ * This is the main routine. The TestRunnerClient is initialized and run. The
+ * CppUnit tests are created, executed, and sent to the CppUnitServer.
+ * If no connection to the CppUnitServer was established the CppUnit tests are
+ * displayed on the console.
+ *
+ * @return <code>0</code> if the results of the CppUnit tests were sent to the
+ *         CppUnitServer successfully.
+ *         <code>-1</code> if a connection could not be established to the
+ *         CppUnitServer.
+ */
+int CPPUNIT_MAIN(int n, char *arg[])
+{
+	TestRunnerClient client;
+
+	client.Init(n, arg);
+	int ret = client.Run();
+	if (ret == -1)
+	{
+		CppUnit::TestFactoryRegistry &registry = CppUnit::TestFactoryRegistry::getRegistry();
+		CppUnit::Test *suite = registry.makeTest();
+
+		CppUnit::TextUi::TestRunner *runner = NULL;
+		runner = new CppUnit::TextUi::TestRunner();
+		runner->addTest(suite);
+		runner->run();
+	}
+
+	exit(ret);
+}
+
+#endif /*CPPUNIT_MAIN*/
Index: TestRunnerClient.h
===================================================================
--- TestRunnerClient.h	(revision a80f4195d731fd366a976130725a3e131376108f)
+++ TestRunnerClient.h	(revision a80f4195d731fd366a976130725a3e131376108f)
@@ -0,0 +1,140 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Gerhard Leonhartsberger.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *******************************************************************************/
+
+#ifndef TESTRUNNERSERVER_H_
+#define TESTRUNNERSERVER_H_
+
+#ifdef CPPUNIT_MAIN
+
+#include "cppunit/TestListener.h"
+
+#include <vector>
+#include <string>
+
+/*!
+ * Class <code>TestRunnerClient</code> handles the network connection to the
+ * <code>CppUnitServer</code> and executes all registered CppUnit tests.
+ * <p>
+ * The meta data of the CppUnit tests and the test results are sent to the
+ * <code>CppUnitServer</code> for displaying.
+ * </p>
+ * <p>
+ * For debugging purposes class <code>TestRunnerClient</code> displays debug
+ * messages on <code>std.cerr</code>. The debug modus is activated by specifying
+ * <code>debug</code> command line option. The command line is parsed by method
+ * <code>Init()</code>.
+ * </p>
+ * <p>
+ * Note: This class is not intended to be subclassed by clients. This class is
+ * based on the original <code>RemoteTestRunner</code> class provided by
+ * <code>org.eclipse.cdt.cppunit</code>.
+ * </p>
+ *
+ * @author Gerhard Leonhartsberger
+ */
+class TestRunnerClient: public CppUnit::TestListener
+{
+private:
+	CppUnit::TestResult *fTestResult;
+	int fClientSocket;
+	char *fHost;
+	int fPort;
+	int fDebugMode;
+	int fKeepAlive;
+
+public:
+	TestRunnerClient();
+	virtual ~TestRunnerClient();
+
+	/*!
+	 * Initializes the <code>TestRunnerClient</code>.
+	 * <p>
+	 * The given <code>args</code> are parsed. The syntax for the arguments is
+	 * defined in EBNF as follows: <code>{-option=value}</code>
+	 * </p>
+	 *
+	 * @param n The number of arguments.
+	 * @param args The argument values. Valid options are:
+	 * 			   <li><code>-debug</code> When present the TestRunnerClient
+	 * 				is run in debug modus and displays debug messages.</li>
+	 * 			   <li><code>-port=number</code> Defines the port where
+	 * 			   CppUnitServer is listening for client connections.</li>
+	 */
+	void Init(int n,char *args[]);
+
+	/*!
+	 * Runs the TestRunnerClient. A trial to connect to the CppUnitServer is done.
+	 * The test results are sent to the CppUnitServer.
+	 *
+	 * @return The return value is <code>0</code> when the CppUnitServer was connected successfully
+	 * otherwise the return value is <code>-1</code>.
+	 */
+	int Run();
+
+	/*!
+	 * Stops processing <code>CppUnit</code> from executing tests.
+	 */
+	void Stop();
+
+	/*!
+	 * Method defined in <code>CppUnit::TestListener</code>.
+	 */
+	void startTest(CppUnit::Test *test);
+
+	/*!
+	 * Method defined in <code>CppUnit::TestListener</code>.
+	 */
+	void addFailure(const CppUnit::TestFailure &failure);
+
+	/*!
+	 * Method defined in <code>CppUnit::TestListener</code>.
+	 */
+	void endTest(CppUnit::Test *test);
+
+private:
+	int Connect();
+	void RunTests();
+	void ShutDown();
+
+	// utility methods
+	void ParseCommandLine(int n, char *args[]);
+	void DefineHostName();
+	void InstallListeners();
+	void UninstallListeners();
+
+	/*!
+	 * Sends the given test to the CppUnitView.
+	 * <p>
+	 * In case of test is of type CppUnit::Test the following protocol is sent:
+	 * <code>TSTTREE name, false, testCaseCount</code>
+	 * </p>
+	 * <p>
+	 * In case of test is of type CppUnit::TestSuite the following protocol is sent:
+	 * TSTTREE name, true, testCount
+	 * </p>
+	 * @param test the CppUnit test
+	 */
+	void SendTestTree(CppUnit::Test *test);
+	void SendMessage(std::string msg);
+
+	// Notification methods
+	void NotifyTestRunStarted(int testCount);
+	void NotifyTestRunEnded(long elapsedTime);
+	void NotifyTestRunStopped(long elapsedTime);
+	void NotifyTestTreeEntry(std::string treeEntry);
+	void NotifyTestStarted(std::string testName);
+	void NotifyTestEnded(std::string testName);
+	void NotifyTestFailed(std::string status, std::string testName, std::string trace);
+
+	std::string GetTrace(const CppUnit::TestFailure &failure);
+	long CurrentTimeMillis();
+	void PrivateSleep(int millisecs);
+};
+
+#endif /*CPPUNIT_MAIN*/
+#endif /*TESTRUNNERSERVER_H_*/
Index: bootstrap
===================================================================
--- bootstrap	(revision a80f4195d731fd366a976130725a3e131376108f)
+++ bootstrap	(revision a80f4195d731fd366a976130725a3e131376108f)
@@ -0,0 +1,19 @@
+#! /bin/sh
+# bootstrap git sources
+# This file is not distributed.
+
+set -x
+
+if git log > ChangeLog.t \
+   && diff ChangeLog.t ChangeLog >/dev/null 2>&1; then
+	mv -f ChangeLog.t ChangeLog
+else
+	rm -f ChangeLog.t
+fi
+
+if test ! -e config; then
+	mkdir config
+fi
+
+
+autoreconf -v -i -I config -I m4
Index: configure.ac
===================================================================
--- configure.ac	(revision a80f4195d731fd366a976130725a3e131376108f)
+++ configure.ac	(revision a80f4195d731fd366a976130725a3e131376108f)
@@ -0,0 +1,59 @@
+#	                              -*- Autoconf -*-
+# Process this file with autoconf to produce a configure script.
+
+AC_PREREQ([2.65])
+AC_INIT([CodePatterns], [0.0.1], [heber@ins.uni-bonn.de])
+AC_CONFIG_AUX_DIR(config)
+AC_CONFIG_SRCDIR([src/Patterns/Singleton_impl.hpp])
+AC_CONFIG_HEADERS([config.h libCodePatterns_config.h])
+AC_CONFIG_MACRO_DIR([m4])
+
+AM_INIT_AUTOMAKE([dist-bzip2 1.11 parallel-tests color-tests])
+
+# Checks for programs.
+AM_PATH_CPPUNIT(1.9.6)
+AC_PROG_CXX
+AC_PROG_INSTALL
+AC_PROG_MAKE_SET
+AM_MISSING_PROG([DOXYGEN], [doxygen])
+
+# use libtool
+LT_INIT([disable-static])
+
+# Define these substitions here to keep all version information in one place.
+# For information on how to properly maintain the library version information,
+# refer to the libtool manual, section "Updating library version information":
+# http://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html
+AC_SUBST([CODEPATTERNS_SO_VERSION], [1:0:0])
+AC_SUBST([CODEPATTERNS_API_VERSION], [1.0.0])
+
+# Checks for libraries.
+# FIXME: Replace `main' with a function in `-ldl':
+AC_CHECK_LIB([dl], [main])
+
+# Boost libraries
+AX_BOOST_BASE([1.40])
+AX_BOOST_THREAD
+
+# Checks for typedefs, structures, and compiler characteristics.
+AC_HEADER_STDBOOL
+AC_C_INLINE
+AC_TYPE_SIZE_T
+
+# Checks for library functions.
+AC_FUNC_MALLOC
+AC_CHECK_FUNCS([floor memset])
+
+AC_CONFIG_FILES([
+  CodePatterns-${CODEPATTERNS_API_VERSION}.pc:CodePatterns.pc.in])
+AC_CONFIG_FILES([
+	Makefile
+	doc/Makefile
+	src/Makefile
+	src/Patterns/Makefile
+	])
+AC_CONFIG_FILES([
+	src/Patterns/unittests/Makefile
+	src/unittests/Makefile
+	])
+AC_OUTPUT
Index: doc/Doxyfile
===================================================================
--- doc/Doxyfile	(revision a80f4195d731fd366a976130725a3e131376108f)
+++ doc/Doxyfile	(revision a80f4195d731fd366a976130725a3e131376108f)
@@ -0,0 +1,260 @@
+# Doxyfile 1.4.5
+
+#---------------------------------------------------------------------------
+# Project related configuration options
+#---------------------------------------------------------------------------
+PROJECT_NAME           = CodePatterns
+PROJECT_NUMBER         = 0.0.1
+OUTPUT_DIRECTORY       = ../doc
+CREATE_SUBDIRS         = NO
+OUTPUT_LANGUAGE        = English
+USE_WINDOWS_ENCODING   = YES
+BRIEF_MEMBER_DESC      = YES
+REPEAT_BRIEF           = YES
+ABBREVIATE_BRIEF       = "The $name class" \
+                         "The $name widget" \
+                         "The $name file" \
+                         is \
+                         provides \
+                         specifies \
+                         contains \
+                         represents \
+                         a \
+                         an \
+                         the
+ALWAYS_DETAILED_SEC    = NO
+INLINE_INHERITED_MEMB  = NO
+FULL_PATH_NAMES        = YES
+STRIP_FROM_PATH        = ../bin/
+STRIP_FROM_INC_PATH    = 
+SHORT_NAMES            = NO
+JAVADOC_AUTOBRIEF      = YES
+MULTILINE_CPP_IS_BRIEF = NO
+DETAILS_AT_TOP         = NO
+INHERIT_DOCS           = YES
+SEPARATE_MEMBER_PAGES  = NO
+TAB_SIZE               = 3
+ALIASES                = 
+OPTIMIZE_OUTPUT_FOR_C  = YES
+OPTIMIZE_OUTPUT_JAVA   = NO
+#BUILTIN_STL_SUPPORT    = NO
+DISTRIBUTE_GROUP_DOC   = NO
+SUBGROUPING            = YES
+#---------------------------------------------------------------------------
+# Build related configuration options
+#---------------------------------------------------------------------------
+EXTRACT_ALL            = YES
+EXTRACT_PRIVATE        = YES
+EXTRACT_STATIC         = YES
+EXTRACT_LOCAL_CLASSES  = YES
+EXTRACT_LOCAL_METHODS  = YES
+HIDE_UNDOC_MEMBERS     = NO
+HIDE_UNDOC_CLASSES     = NO
+HIDE_FRIEND_COMPOUNDS  = NO
+HIDE_IN_BODY_DOCS      = NO
+INTERNAL_DOCS          = YES
+CASE_SENSE_NAMES       = NO
+HIDE_SCOPE_NAMES       = NO
+SHOW_INCLUDE_FILES     = YES
+INLINE_INFO            = YES
+SORT_MEMBER_DOCS       = YES
+SORT_BRIEF_DOCS        = NO
+SORT_BY_SCOPE_NAME     = NO
+GENERATE_TODOLIST      = YES
+GENERATE_TESTLIST      = YES
+GENERATE_BUGLIST       = YES
+GENERATE_DEPRECATEDLIST= YES
+ENABLED_SECTIONS       = 
+MAX_INITIALIZER_LINES  = 30
+SHOW_USED_FILES        = YES
+SHOW_DIRECTORIES       = NO
+FILE_VERSION_FILTER    = 
+#---------------------------------------------------------------------------
+# configuration options related to warning and progress messages
+#---------------------------------------------------------------------------
+QUIET                  = NO
+WARNINGS               = YES
+WARN_IF_UNDOCUMENTED   = YES
+WARN_IF_DOC_ERROR      = YES
+WARN_NO_PARAMDOC       = NO
+WARN_FORMAT            = "$file:$line: $text"
+WARN_LOGFILE           = 
+#---------------------------------------------------------------------------
+# configuration options related to the input files
+#---------------------------------------------------------------------------
+INPUT                  = ../src
+FILE_PATTERNS          = *.c \
+                         *.cc \
+                         *.cxx \
+                         *.cpp \
+                         *.c++ \
+                         *.d \
+                         *.java \
+                         *.ii \
+                         *.ixx \
+                         *.ipp \
+                         *.i++ \
+                         *.inl \
+                         *.h \
+                         *.hh \
+                         *.hxx \
+                         *.hpp \
+                         *.h++ \
+                         *.idl \
+                         *.odl \
+                         *.cs \
+                         *.php \
+                         *.php3 \
+                         *.inc \
+                         *.m \
+                         *.mm \
+                         *.dox \
+                         *.py
+RECURSIVE              = YES
+EXCLUDE                = 
+EXCLUDE_SYMLINKS       = NO
+EXCLUDE_PATTERNS       = */unittests/* \
+						 */test/*
+EXAMPLE_PATH           = 
+EXAMPLE_PATTERNS       = *
+EXAMPLE_RECURSIVE      = NO
+IMAGE_PATH             = 
+INPUT_FILTER           = 
+FILTER_PATTERNS        = 
+FILTER_SOURCE_FILES    = NO
+#---------------------------------------------------------------------------
+# configuration options related to source browsing
+#---------------------------------------------------------------------------
+SOURCE_BROWSER         = YES
+INLINE_SOURCES         = YES
+STRIP_CODE_COMMENTS    = NO
+REFERENCED_BY_RELATION = NO
+REFERENCES_RELATION    = NO
+USE_HTAGS              = NO
+VERBATIM_HEADERS       = NO
+#---------------------------------------------------------------------------
+# configuration options related to the alphabetical class index
+#---------------------------------------------------------------------------
+ALPHABETICAL_INDEX     = NO
+COLS_IN_ALPHA_INDEX    = 5
+IGNORE_PREFIX          = 
+#---------------------------------------------------------------------------
+# configuration options related to the HTML output
+#---------------------------------------------------------------------------
+GENERATE_HTML          = YES
+HTML_OUTPUT            = html
+HTML_FILE_EXTENSION    = .html
+HTML_HEADER            = 
+HTML_FOOTER            = 
+HTML_STYLESHEET        = 
+HTML_ALIGN_MEMBERS     = YES
+GENERATE_HTMLHELP      = NO
+CHM_FILE               = 
+HHC_LOCATION           = 
+GENERATE_CHI           = NO
+BINARY_TOC             = NO
+TOC_EXPAND             = NO
+DISABLE_INDEX          = NO
+ENUM_VALUES_PER_LINE   = 4
+GENERATE_TREEVIEW      = NO
+TREEVIEW_WIDTH         = 250
+#---------------------------------------------------------------------------
+# configuration options related to the LaTeX output
+#---------------------------------------------------------------------------
+GENERATE_LATEX         = NO
+LATEX_OUTPUT           = latex
+LATEX_CMD_NAME         = latex
+MAKEINDEX_CMD_NAME     = makeindex
+COMPACT_LATEX          = NO
+PAPER_TYPE             = a4wide
+EXTRA_PACKAGES         = 
+LATEX_HEADER           = 
+PDF_HYPERLINKS         = YES
+USE_PDFLATEX           = YES
+LATEX_BATCHMODE        = NO
+LATEX_HIDE_INDICES     = NO
+#---------------------------------------------------------------------------
+# configuration options related to the RTF output
+#---------------------------------------------------------------------------
+GENERATE_RTF           = NO
+RTF_OUTPUT             = rtf
+COMPACT_RTF            = NO
+RTF_HYPERLINKS         = NO
+RTF_STYLESHEET_FILE    = 
+RTF_EXTENSIONS_FILE    = 
+#---------------------------------------------------------------------------
+# configuration options related to the man page output
+#---------------------------------------------------------------------------
+GENERATE_MAN           = NO
+MAN_OUTPUT             = man
+MAN_EXTENSION          = .3
+MAN_LINKS              = NO
+#---------------------------------------------------------------------------
+# configuration options related to the XML output
+#---------------------------------------------------------------------------
+GENERATE_XML           = NO
+XML_OUTPUT             = xml
+XML_SCHEMA             = 
+XML_DTD                = 
+XML_PROGRAMLISTING     = YES
+#---------------------------------------------------------------------------
+# configuration options for the AutoGen Definitions output
+#---------------------------------------------------------------------------
+GENERATE_AUTOGEN_DEF   = NO
+#---------------------------------------------------------------------------
+# configuration options related to the Perl module output
+#---------------------------------------------------------------------------
+GENERATE_PERLMOD       = NO
+PERLMOD_LATEX          = NO
+PERLMOD_PRETTY         = YES
+PERLMOD_MAKEVAR_PREFIX = 
+#---------------------------------------------------------------------------
+# Configuration options related to the preprocessor   
+#---------------------------------------------------------------------------
+ENABLE_PREPROCESSING   = YES
+MACRO_EXPANSION        = NO
+EXPAND_ONLY_PREDEF     = NO
+SEARCH_INCLUDES        = YES
+INCLUDE_PATH           = 
+INCLUDE_FILE_PATTERNS  = 
+PREDEFINED             = 
+EXPAND_AS_DEFINED      = 
+SKIP_FUNCTION_MACROS   = YES
+#---------------------------------------------------------------------------
+# Configuration::additions related to external references   
+#---------------------------------------------------------------------------
+TAGFILES               = 
+GENERATE_TAGFILE       = 
+ALLEXTERNALS           = NO
+EXTERNAL_GROUPS        = YES
+PERL_PATH              = /usr/bin/perl
+#---------------------------------------------------------------------------
+# Configuration options related to the dot tool   
+#---------------------------------------------------------------------------
+CLASS_DIAGRAMS         = YES
+HIDE_UNDOC_RELATIONS   = YES
+HAVE_DOT               = NO
+CLASS_GRAPH            = YES
+COLLABORATION_GRAPH    = YES
+GROUP_GRAPHS           = YES
+UML_LOOK               = NO
+TEMPLATE_RELATIONS     = NO
+INCLUDE_GRAPH          = YES
+INCLUDED_BY_GRAPH      = YES
+CALL_GRAPH             = NO
+GRAPHICAL_HIERARCHY    = YES
+DIRECTORY_GRAPH        = YES
+DOT_IMAGE_FORMAT       = png
+DOT_PATH               = 
+DOTFILE_DIRS           = 
+MAX_DOT_GRAPH_WIDTH    = 1024
+MAX_DOT_GRAPH_HEIGHT   = 1024
+MAX_DOT_GRAPH_DEPTH    = 1000
+DOT_TRANSPARENT        = NO
+DOT_MULTI_TARGETS      = NO
+GENERATE_LEGEND        = YES
+DOT_CLEANUP            = YES
+#---------------------------------------------------------------------------
+# Configuration::additions related to the search engine   
+#---------------------------------------------------------------------------
+SEARCHENGINE           = YES
Index: doc/Makefile.am
===================================================================
--- doc/Makefile.am	(revision a80f4195d731fd366a976130725a3e131376108f)
+++ doc/Makefile.am	(revision a80f4195d731fd366a976130725a3e131376108f)
@@ -0,0 +1,48 @@
+EXTRA_DIST = \
+	Doxyfile \
+	html
+
+SRCMANDOCS =
+
+GENMANDOCS =
+
+dist_man_MANS = $(SRCMANDOCS) $(GENMANDOCS)
+dist_doc_DATA = $(PDFFILES)
+
+SUFFIXES = .pdf .ps .dvi .tex .xml .html
+
+html-local: doxygen-docs
+
+doxygen-docs:
+	cd $(srcdir) && $(DOXYGEN)
+
+.xml.ps:
+	$(XMLTO) $(XMLTOFLAGS) ps $<
+	@touch $@
+
+.xml.html:
+	$(XMLTO) $(XMLTOFLAGS) html-nochunks $<
+	@touch $@
+
+CodePatterns.stamp: CodePatterns.xml
+	@rm -f CodePatterns.tmp
+	@touch CodePatterns.tmp
+	$(XMLTO) $(XMLTOFLAGS) man $<
+	@touch $(GENMANDOCS)
+	@mv -f CodePatterns.tmp $@
+
+$(GENMANDOCS): CodePatterns.stamp
+	@if test -f $@; then touch $@; else \
+	  rm -f CodePatterns.stamp; \
+	  $(MAKE) $(AM_MAKEFLAGS) CodePatterns.stamp; \
+	fi
+
+clean-local: 
+	rm -f *.aux *.bbl *.blg *.log *.aux.bak
+distclean-local:
+	rm -f *.dvi *.ps *.pdf *.html $(GENMANDOCS) CodePatterns.stamp
+
+.PHONY: allclean doxygen-docs
+allclean: distclean
+
+
Index: m4/ac_doxygen.m4
===================================================================
--- m4/ac_doxygen.m4	(revision a80f4195d731fd366a976130725a3e131376108f)
+++ m4/ac_doxygen.m4	(revision a80f4195d731fd366a976130725a3e131376108f)
@@ -0,0 +1,312 @@
+# This file is part of Autoconf.                       -*- Autoconf -*-
+
+# Copyright (C) 2004 Oren Ben-Kiki
+# This file is distributed under the same terms as the Autoconf macro files.
+
+# Generate automatic documentation using Doxygen. Works in concert with the
+# aminclude.m4 file and a compatible doxygen configuration file. Defines the
+# following public macros:
+#
+# DX_???_FEATURE(ON|OFF) - control the default setting fo a Doxygen feature.
+# Supported features are 'DOXYGEN' itself, 'DOT' for generating graphics,
+# 'HTML' for plain HTML, 'CHM' for compressed HTML help (for MS users), 'CHI'
+# for generating a seperate .chi file by the .chm file, and 'MAN', 'RTF',
+# 'XML', 'PDF' and 'PS' for the appropriate output formats. The environment
+# variable DOXYGEN_PAPER_SIZE may be specified to override the default 'a4wide'
+# paper size.
+#
+# By default, HTML, PDF and PS documentation is generated as this seems to be
+# the most popular and portable combination. MAN pages created by Doxygen are
+# usually problematic, though by picking an appropriate subset and doing some
+# massaging they might be better than nothing. CHM and RTF are specific for MS
+# (note that you can't generate both HTML and CHM at the same time). The XML is
+# rather useless unless you apply specialized post-processing to it.
+#
+# The macro mainly controls the default state of the feature. The use can
+# override the default by specifying --enable or --disable. The macros ensure
+# that contradictory flags are not given (e.g., --enable-doxygen-html and
+# --enable-doxygen-chm, --enable-doxygen-anything with --disable-doxygen, etc.)
+# Finally, each feature will be automatically disabled (with a warning) if the
+# required programs are missing.
+#
+# Once all the feature defaults have been specified, call DX_INIT_DOXYGEN with
+# the following parameters: a one-word name for the project for use as a
+# filename base etc., an optional configuration file name (the default is
+# 'Doxyfile', the same as Doxygen's default), and an optional output directory
+# name (the default is 'doxygen-doc').
+
+## ----------##
+## Defaults. ##
+## ----------##
+
+DX_ENV=""
+AC_DEFUN([DX_FEATURE_doc],  ON)
+AC_DEFUN([DX_FEATURE_dot],  ON)
+AC_DEFUN([DX_FEATURE_man],  OFF)
+AC_DEFUN([DX_FEATURE_html], ON)
+AC_DEFUN([DX_FEATURE_chm],  OFF)
+AC_DEFUN([DX_FEATURE_chi],  OFF)
+AC_DEFUN([DX_FEATURE_rtf],  OFF)
+AC_DEFUN([DX_FEATURE_xml],  OFF)
+AC_DEFUN([DX_FEATURE_pdf],  ON)
+AC_DEFUN([DX_FEATURE_ps],   ON)
+
+## --------------- ##
+## Private macros. ##
+## --------------- ##
+
+# DX_ENV_APPEND(VARIABLE, VALUE)
+# ------------------------------
+# Append VARIABLE="VALUE" to DX_ENV for invoking doxygen.
+AC_DEFUN([DX_ENV_APPEND], [AC_SUBST([DX_ENV], ["$DX_ENV $1='$2'"])])
+
+# DX_DIRNAME_EXPR
+# ---------------
+# Expand into a shell expression prints the directory part of a path.
+AC_DEFUN([DX_DIRNAME_EXPR],
+         [[expr ".$1" : '\(\.\)[^/]*$' \| "x$1" : 'x\(.*\)/[^/]*$']])
+
+# DX_IF_FEATURE(FEATURE, IF-ON, IF-OFF)
+# -------------------------------------
+# Expands according to the M4 (static) status of the feature.
+AC_DEFUN([DX_IF_FEATURE], [ifelse(DX_FEATURE_$1, ON, [$2], [$3])])
+
+# DX_REQUIRE_PROG(VARIABLE, PROGRAM)
+# ----------------------------------
+# Require the specified program to be found for the DX_CURRENT_FEATURE to work.
+AC_DEFUN([DX_REQUIRE_PROG], [
+AC_PATH_TOOL([$1], [$2])
+if test "$DX_FLAG_[]DX_CURRENT_FEATURE$$1" = 1; then
+    AC_MSG_WARN([$2 not found - will not DX_CURRENT_DESCRIPTION])
+    AC_SUBST([DX_FLAG_[]DX_CURRENT_FEATURE], 0)
+fi
+])
+
+# DX_TEST_FEATURE(FEATURE)
+# ------------------------
+# Expand to a shell expression testing whether the feature is active.
+AC_DEFUN([DX_TEST_FEATURE], [test "$DX_FLAG_$1" = 1])
+
+# DX_CHECK_DEPEND(REQUIRED_FEATURE, REQUIRED_STATE)
+# -------------------------------------------------
+# Verify that a required features has the right state before trying to turn on
+# the DX_CURRENT_FEATURE.
+AC_DEFUN([DX_CHECK_DEPEND], [
+test "$DX_FLAG_$1" = "$2" \
+|| AC_MSG_ERROR([doxygen-DX_CURRENT_FEATURE ifelse([$2], 1,
+                            requires, contradicts) doxygen-DX_CURRENT_FEATURE])
+])
+
+# DX_CLEAR_DEPEND(FEATURE, REQUIRED_FEATURE, REQUIRED_STATE)
+# ----------------------------------------------------------
+# Turn off the DX_CURRENT_FEATURE if the required feature is off.
+AC_DEFUN([DX_CLEAR_DEPEND], [
+test "$DX_FLAG_$1" = "$2" || AC_SUBST([DX_FLAG_[]DX_CURRENT_FEATURE], 0)
+])
+
+# DX_FEATURE_ARG(FEATURE, DESCRIPTION,
+#                CHECK_DEPEND, CLEAR_DEPEND,
+#                REQUIRE, DO-IF-ON, DO-IF-OFF)
+# --------------------------------------------
+# Parse the command-line option controlling a feature. CHECK_DEPEND is called
+# if the user explicitly turns the feature on (and invokes DX_CHECK_DEPEND),
+# otherwise CLEAR_DEPEND is called to turn off the default state if a required
+# feature is disabled (using DX_CLEAR_DEPEND). REQUIRE performs additional
+# requirement tests (DX_REQUIRE_PROG). Finally, an automake flag is set and
+# DO-IF-ON or DO-IF-OFF are called according to the final state of the feature.
+AC_DEFUN([DX_ARG_ABLE], [
+    AC_DEFUN([DX_CURRENT_FEATURE], [$1])
+    AC_DEFUN([DX_CURRENT_DESCRIPTION], [$2])
+    AC_ARG_ENABLE(doxygen-$1,
+                  [AS_HELP_STRING(DX_IF_FEATURE([$1], [--disable-doxygen-$1],
+                                                      [--enable-doxygen-$1]),
+                                  DX_IF_FEATURE([$1], [don't $2], [$2]))],
+                  [
+case "$enableval" in
+#(
+y|Y|yes|Yes|YES)
+    AC_SUBST([DX_FLAG_$1], 1)
+    $3
+;; #(
+n|N|no|No|NO)
+    AC_SUBST([DX_FLAG_$1], 0)
+;; #(
+*)
+    AC_MSG_ERROR([invalid value '$enableval' given to doxygen-$1])
+;;
+esac
+], [
+AC_SUBST([DX_FLAG_$1], [DX_IF_FEATURE([$1], 1, 0)])
+$4
+])
+if DX_TEST_FEATURE([$1]); then
+    $5
+    :
+fi
+if DX_TEST_FEATURE([$1]); then
+    AM_CONDITIONAL(DX_COND_$1, :)
+    $6
+    :
+else
+    AM_CONDITIONAL(DX_COND_$1, false)
+    $7
+    :
+fi
+])
+
+## -------------- ##
+## Public macros. ##
+## -------------- ##
+
+# DX_XXX_FEATURE(DEFAULT_STATE)
+# -----------------------------
+AC_DEFUN([DX_DOXYGEN_FEATURE], [AC_DEFUN([DX_FEATURE_doc],  [$1])])
+AC_DEFUN([DX_MAN_FEATURE],     [AC_DEFUN([DX_FEATURE_man],  [$1])])
+AC_DEFUN([DX_HTML_FEATURE],    [AC_DEFUN([DX_FEATURE_html], [$1])])
+AC_DEFUN([DX_CHM_FEATURE],     [AC_DEFUN([DX_FEATURE_chm],  [$1])])
+AC_DEFUN([DX_CHI_FEATURE],     [AC_DEFUN([DX_FEATURE_chi],  [$1])])
+AC_DEFUN([DX_RTF_FEATURE],     [AC_DEFUN([DX_FEATURE_rtf],  [$1])])
+AC_DEFUN([DX_XML_FEATURE],     [AC_DEFUN([DX_FEATURE_xml],  [$1])])
+AC_DEFUN([DX_XML_FEATURE],     [AC_DEFUN([DX_FEATURE_xml],  [$1])])
+AC_DEFUN([DX_PDF_FEATURE],     [AC_DEFUN([DX_FEATURE_pdf],  [$1])])
+AC_DEFUN([DX_PS_FEATURE],      [AC_DEFUN([DX_FEATURE_ps],   [$1])])
+
+# DX_INIT_DOXYGEN(PROJECT, [CONFIG-FILE], [OUTPUT-DOC-DIR])
+# ---------------------------------------------------------
+# PROJECT also serves as the base name for the documentation files.
+# The default CONFIG-FILE is "Doxyfile" and OUTPUT-DOC-DIR is "doxygen-doc".
+AC_DEFUN([DX_INIT_DOXYGEN], [
+
+# Files:
+AC_SUBST([DX_PROJECT], [$1])
+AC_SUBST([DX_CONFIG], [ifelse([$2], [], Doxyfile, [$2])])
+AC_SUBST([DX_DOCDIR], [ifelse([$3], [], doxygen-doc, [$3])])
+
+# Environment variables used inside doxygen.cfg:
+DX_ENV_APPEND(SRCDIR, $srcdir)
+DX_ENV_APPEND(PROJECT, $DX_PROJECT)
+DX_ENV_APPEND(DOCDIR, $DX_DOCDIR)
+DX_ENV_APPEND(VERSION, $PACKAGE_VERSION)
+
+# Doxygen itself:
+DX_ARG_ABLE(doc, [generate any doxygen documentation],
+            [],
+            [],
+            [DX_REQUIRE_PROG([DX_DOXYGEN], doxygen)
+             DX_REQUIRE_PROG([DX_PERL], perl)],
+            [DX_ENV_APPEND(PERL_PATH, $DX_PERL)])
+
+# Dot for graphics:
+DX_ARG_ABLE(dot, [generate graphics for doxygen documentation],
+            [DX_CHECK_DEPEND(doc, 1)],
+            [DX_CLEAR_DEPEND(doc, 1)],
+            [DX_REQUIRE_PROG([DX_DOT], dot)],
+            [DX_ENV_APPEND(HAVE_DOT, YES)
+             DX_ENV_APPEND(DOT_PATH, [`DX_DIRNAME_EXPR($DX_DOT)`])],
+            [DX_ENV_APPEND(HAVE_DOT, NO)])
+
+# Man pages generation:
+DX_ARG_ABLE(man, [generate doxygen manual pages],
+            [DX_CHECK_DEPEND(doc, 1)],
+            [DX_CLEAR_DEPEND(doc, 1)],
+            [],
+            [DX_ENV_APPEND(GENERATE_MAN, YES)],
+            [DX_ENV_APPEND(GENERATE_MAN, NO)])
+
+# RTF file generation:
+DX_ARG_ABLE(rtf, [generate doxygen RTF documentation],
+            [DX_CHECK_DEPEND(doc, 1)],
+            [DX_CLEAR_DEPEND(doc, 1)],
+            [],
+            [DX_ENV_APPEND(GENERATE_RTF, YES)],
+            [DX_ENV_APPEND(GENERATE_RTF, NO)])
+
+# XML file generation:
+DX_ARG_ABLE(xml, [generate doxygen XML documentation],
+            [DX_CHECK_DEPEND(doc, 1)],
+            [DX_CLEAR_DEPEND(doc, 1)],
+            [],
+            [DX_ENV_APPEND(GENERATE_XML, YES)],
+            [DX_ENV_APPEND(GENERATE_XML, NO)])
+
+# (Compressed) HTML help generation:
+DX_ARG_ABLE(chm, [generate doxygen compressed HTML help documentation],
+            [DX_CHECK_DEPEND(doc, 1)],
+            [DX_CLEAR_DEPEND(doc, 1)],
+            [DX_REQUIRE_PROG([DX_HHC], hhc)],
+            [DX_ENV_APPEND(HHC_PATH, $DX_HHC)
+             DX_ENV_APPEND(GENERATE_HTML, YES)
+             DX_ENV_APPEND(GENERATE_HTMLHELP, YES)],
+            [DX_ENV_APPEND(GENERATE_HTMLHELP, NO)])
+
+# Seperate CHI file generation.
+DX_ARG_ABLE(chi, [generate doxygen seperate compressed HTML help index file],
+            [DX_CHECK_DEPEND(chm, 1)],
+            [DX_CLEAR_DEPEND(chm, 1)],
+            [],
+            [DX_ENV_APPEND(GENERATE_CHI, YES)],
+            [DX_ENV_APPEND(GENERATE_CHI, NO)])
+
+# Plain HTML pages generation:
+DX_ARG_ABLE(html, [generate doxygen plain HTML documentation],
+            [DX_CHECK_DEPEND(doc, 1) DX_CHECK_DEPEND(chm, 0)],
+            [DX_CLEAR_DEPEND(doc, 1) DX_CLEAR_DEPEND(chm, 0)],
+            [],
+            [DX_ENV_APPEND(GENERATE_HTML, YES)],
+            [DX_TEST_FEATURE(chm) || DX_ENV_APPEND(GENERATE_HTML, NO)])
+
+# PostScript file generation:
+DX_ARG_ABLE(ps, [generate doxygen PostScript documentation],
+            [DX_CHECK_DEPEND(doc, 1)],
+            [DX_CLEAR_DEPEND(doc, 1)],
+            [DX_REQUIRE_PROG([DX_LATEX], latex)
+             DX_REQUIRE_PROG([DX_MAKEINDEX], makeindex)
+             DX_REQUIRE_PROG([DX_DVIPS], dvips)
+             DX_REQUIRE_PROG([DX_EGREP], egrep)])
+
+# PDF file generation:
+DX_ARG_ABLE(pdf, [generate doxygen PDF documentation],
+            [DX_CHECK_DEPEND(doc, 1)],
+            [DX_CLEAR_DEPEND(doc, 1)],
+            [DX_REQUIRE_PROG([DX_PDFLATEX], pdflatex)
+             DX_REQUIRE_PROG([DX_MAKEINDEX], makeindex)
+             DX_REQUIRE_PROG([DX_EGREP], egrep)])
+
+# LaTeX generation for PS and/or PDF:
+if DX_TEST_FEATURE(ps) || DX_TEST_FEATURE(pdf); then
+    AM_CONDITIONAL(DX_COND_latex, :)
+    DX_ENV_APPEND(GENERATE_LATEX, YES)
+else
+    AM_CONDITIONAL(DX_COND_latex, false)
+    DX_ENV_APPEND(GENERATE_LATEX, NO)
+fi
+
+# Paper size for PS and/or PDF:
+AC_ARG_VAR(DOXYGEN_PAPER_SIZE,
+           [a4wide (default), a4, letter, legal or executive])
+case "$DOXYGEN_PAPER_SIZE" in
+#(
+"")
+    AC_SUBST(DOXYGEN_PAPER_SIZE, "")
+;; #(
+a4wide|a4|letter|legal|executive)
+    DX_ENV_APPEND(PAPER_SIZE, $DOXYGEN_PAPER_SIZE)
+;; #(
+*)
+    AC_MSG_ERROR([unknown DOXYGEN_PAPER_SIZE='$DOXYGEN_PAPER_SIZE'])
+;;
+esac
+
+#For debugging:
+#echo DX_FLAG_doc=$DX_FLAG_doc
+#echo DX_FLAG_dot=$DX_FLAG_dot
+#echo DX_FLAG_man=$DX_FLAG_man
+#echo DX_FLAG_html=$DX_FLAG_html
+#echo DX_FLAG_chm=$DX_FLAG_chm
+#echo DX_FLAG_chi=$DX_FLAG_chi
+#echo DX_FLAG_rtf=$DX_FLAG_rtf
+#echo DX_FLAG_xml=$DX_FLAG_xml
+#echo DX_FLAG_pdf=$DX_FLAG_pdf
+#echo DX_FLAG_ps=$DX_FLAG_ps
+#echo DX_ENV=$DX_ENV
+])
Index: m4/ax_boost_base.m4
===================================================================
--- m4/ax_boost_base.m4	(revision a80f4195d731fd366a976130725a3e131376108f)
+++ m4/ax_boost_base.m4	(revision a80f4195d731fd366a976130725a3e131376108f)
@@ -0,0 +1,219 @@
+# ===========================================================================
+#          http://www.nongnu.org/autoconf-archive/ax_boost_base.html
+# ===========================================================================
+#
+# SYNOPSIS
+#
+#   AX_BOOST_BASE([MINIMUM-VERSION])
+#
+# DESCRIPTION
+#
+#   Test for the Boost C++ libraries of a particular version (or newer)
+#
+#   If no path to the installed boost library is given the macro searchs
+#   under /usr, /usr/local, /opt and /opt/local and evaluates the
+#   $BOOST_ROOT environment variable. Further documentation is available at
+#   <http://randspringer.de/boost/index.html>.
+#
+#   This macro calls:
+#
+#     AC_SUBST(BOOST_CPPFLAGS) / AC_SUBST(BOOST_LDFLAGS)
+#
+#   And sets:
+#
+#     HAVE_BOOST
+#
+# LICENSE
+#
+#   Copyright (c) 2008 Thomas Porschberg <thomas@randspringer.de>
+#
+#   Copying and distribution of this file, with or without modification, are
+#   permitted in any medium without royalty provided the copyright notice
+#   and this notice are preserved.
+
+AC_DEFUN([AX_BOOST_BASE],
+[
+AC_ARG_WITH([boost],
+	AS_HELP_STRING([--with-boost@<:@=DIR@:>@], [use boost (default is yes) - it is possible to specify the root directory for boost (optional)]),
+	[
+    if test "$withval" = "no"; then
+		want_boost="no"
+    elif test "$withval" = "yes"; then
+        want_boost="yes"
+        ac_boost_path=""
+    else
+	    want_boost="yes"
+        ac_boost_path="$withval"
+	fi
+    ],
+    [want_boost="yes"])
+
+
+AC_ARG_WITH([boost-libdir],
+        AS_HELP_STRING([--with-boost-libdir=LIB_DIR],
+        [Force given directory for boost libraries. Note that this will overwrite library path detection, so use this parameter only if default library detection fails and you know exactly where your boost libraries are located.]),
+        [
+        if test -d $withval
+        then
+                ac_boost_lib_path="$withval"
+        else
+                AC_MSG_ERROR(--with-boost-libdir expected directory name)
+        fi
+        ],
+        [ac_boost_lib_path=""]
+)
+
+if test "x$want_boost" = "xyes"; then
+	boost_lib_version_req=ifelse([$1], ,1.20.0,$1)
+	boost_lib_version_req_shorten=`expr $boost_lib_version_req : '\([[0-9]]*\.[[0-9]]*\)'`
+	boost_lib_version_req_major=`expr $boost_lib_version_req : '\([[0-9]]*\)'`
+	boost_lib_version_req_minor=`expr $boost_lib_version_req : '[[0-9]]*\.\([[0-9]]*\)'`
+	boost_lib_version_req_sub_minor=`expr $boost_lib_version_req : '[[0-9]]*\.[[0-9]]*\.\([[0-9]]*\)'`
+	if test "x$boost_lib_version_req_sub_minor" = "x" ; then
+		boost_lib_version_req_sub_minor="0"
+    	fi
+	WANT_BOOST_VERSION=`expr $boost_lib_version_req_major \* 100000 \+  $boost_lib_version_req_minor \* 100 \+ $boost_lib_version_req_sub_minor`
+	AC_MSG_CHECKING(for boostlib >= $boost_lib_version_req)
+	succeeded=no
+
+	dnl first we check the system location for boost libraries
+	dnl this location ist chosen if boost libraries are installed with the --layout=system option
+	dnl or if you install boost with RPM
+	if test "$ac_boost_path" != ""; then
+		BOOST_LDFLAGS="-L$ac_boost_path/lib"
+		BOOST_CPPFLAGS="-I$ac_boost_path/include"
+	else
+		for ac_boost_path_tmp in /usr /usr/local /opt /opt/local ; do
+			if test -d "$ac_boost_path_tmp/include/boost" && test -r "$ac_boost_path_tmp/include/boost"; then
+				BOOST_LDFLAGS="-L$ac_boost_path_tmp/lib"
+				BOOST_CPPFLAGS="-I$ac_boost_path_tmp/include"
+				break;
+			fi
+		done
+	fi
+
+    dnl overwrite ld flags if we have required special directory with
+    dnl --with-boost-libdir parameter
+    if test "$ac_boost_lib_path" != ""; then
+       BOOST_LDFLAGS="-L$ac_boost_lib_path"
+    fi
+
+	CPPFLAGS_SAVED="$CPPFLAGS"
+	CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
+	export CPPFLAGS
+
+	LDFLAGS_SAVED="$LDFLAGS"
+	LDFLAGS="$LDFLAGS $BOOST_LDFLAGS"
+	export LDFLAGS
+
+	AC_LANG_PUSH(C++)
+     	AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
+	@%:@include <boost/version.hpp>
+	]], [[
+	#if BOOST_VERSION >= $WANT_BOOST_VERSION
+	// Everything is okay
+	#else
+	#  error Boost version is too old
+	#endif
+	]])],[
+        AC_MSG_RESULT(yes)
+	succeeded=yes
+	found_system=yes
+       	],[
+       	])
+	AC_LANG_POP([C++])
+
+
+
+	dnl if we found no boost with system layout we search for boost libraries
+	dnl built and installed without the --layout=system option or for a staged(not installed) version
+	if test "x$succeeded" != "xyes"; then
+		_version=0
+		if test "$ac_boost_path" != ""; then
+			if test -d "$ac_boost_path" && test -r "$ac_boost_path"; then
+				for i in `ls -d $ac_boost_path/include/boost-* 2>/dev/null`; do
+					_version_tmp=`echo $i | sed "s#$ac_boost_path##" | sed 's/\/include\/boost-//' | sed 's/_/./'`
+					V_CHECK=`expr $_version_tmp \> $_version`
+					if test "$V_CHECK" = "1" ; then
+						_version=$_version_tmp
+					fi
+					VERSION_UNDERSCORE=`echo $_version | sed 's/\./_/'`
+					BOOST_CPPFLAGS="-I$ac_boost_path/include/boost-$VERSION_UNDERSCORE"
+				done
+			fi
+		else
+			for ac_boost_path in /usr /usr/local /opt /opt/local ; do
+				if test -d "$ac_boost_path" && test -r "$ac_boost_path"; then
+					for i in `ls -d $ac_boost_path/include/boost-* 2>/dev/null`; do
+						_version_tmp=`echo $i | sed "s#$ac_boost_path##" | sed 's/\/include\/boost-//' | sed 's/_/./'`
+						V_CHECK=`expr $_version_tmp \> $_version`
+						if test "$V_CHECK" = "1" ; then
+							_version=$_version_tmp
+	               					best_path=$ac_boost_path
+						fi
+					done
+				fi
+			done
+
+			VERSION_UNDERSCORE=`echo $_version | sed 's/\./_/'`
+			BOOST_CPPFLAGS="-I$best_path/include/boost-$VERSION_UNDERSCORE"
+            if test "$ac_boost_lib_path" = ""
+            then
+               BOOST_LDFLAGS="-L$best_path/lib"
+            fi
+
+	    		if test "x$BOOST_ROOT" != "x"; then
+				if test -d "$BOOST_ROOT" && test -r "$BOOST_ROOT" && test -d "$BOOST_ROOT/stage/lib" && test -r "$BOOST_ROOT/stage/lib"; then
+					version_dir=`expr //$BOOST_ROOT : '.*/\(.*\)'`
+					stage_version=`echo $version_dir | sed 's/boost_//' | sed 's/_/./g'`
+			        	stage_version_shorten=`expr $stage_version : '\([[0-9]]*\.[[0-9]]*\)'`
+					V_CHECK=`expr $stage_version_shorten \>\= $_version`
+                    if test "$V_CHECK" = "1" -a "$ac_boost_lib_path" = "" ; then
+						AC_MSG_NOTICE(We will use a staged boost library from $BOOST_ROOT)
+						BOOST_CPPFLAGS="-I$BOOST_ROOT"
+						BOOST_LDFLAGS="-L$BOOST_ROOT/stage/lib"
+					fi
+				fi
+	    		fi
+		fi
+
+		CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
+		export CPPFLAGS
+		LDFLAGS="$LDFLAGS $BOOST_LDFLAGS"
+		export LDFLAGS
+
+		AC_LANG_PUSH(C++)
+	     	AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
+		@%:@include <boost/version.hpp>
+		]], [[
+		#if BOOST_VERSION >= $WANT_BOOST_VERSION
+		// Everything is okay
+		#else
+		#  error Boost version is too old
+		#endif
+		]])],[
+        	AC_MSG_RESULT(yes)
+		succeeded=yes
+		found_system=yes
+       		],[
+	       	])
+		AC_LANG_POP([C++])
+	fi
+
+	if test "$succeeded" != "yes" ; then
+		if test "$_version" = "0" ; then
+			AC_MSG_ERROR([[We could not detect the boost libraries (version $boost_lib_version_req_shorten or higher). If you have a staged boost library (still not installed) please specify \$BOOST_ROOT in your environment and do not give a PATH to --with-boost option.  If you are sure you have boost installed, then check your version number looking in <boost/version.hpp>. See http://randspringer.de/boost for more documentation.]])
+		else
+			AC_MSG_NOTICE([Your boost libraries seems to old (version $_version).])
+		fi
+	else
+		AC_SUBST(BOOST_CPPFLAGS)
+		AC_SUBST(BOOST_LDFLAGS)
+		AC_DEFINE(HAVE_BOOST,,[define if the Boost library is available])
+	fi
+
+        CPPFLAGS="$CPPFLAGS_SAVED"
+       	LDFLAGS="$LDFLAGS_SAVED"
+fi
+
+])
Index: m4/m4_ax_boost_thread.m4
===================================================================
--- m4/m4_ax_boost_thread.m4	(revision a80f4195d731fd366a976130725a3e131376108f)
+++ m4/m4_ax_boost_thread.m4	(revision a80f4195d731fd366a976130725a3e131376108f)
@@ -0,0 +1,146 @@
+# ===========================================================================
+#         http://www.nongnu.org/autoconf-archive/ax_boost_thread.html
+# ===========================================================================
+#
+# SYNOPSIS
+#
+#   AX_BOOST_THREAD
+#
+# DESCRIPTION
+#
+#   Test for Thread library from the Boost C++ libraries. The macro requires
+#   a preceding call to AX_BOOST_BASE. Further documentation is available at
+#   <http://randspringer.de/boost/index.html>.
+#
+#   This macro calls:
+#
+#     AC_SUBST(BOOST_THREAD_LIB)
+#
+#   And sets:
+#
+#     HAVE_BOOST_THREAD
+#
+# LICENSE
+#
+#   Copyright (c) 2009 Thomas Porschberg <thomas@randspringer.de>
+#   Copyright (c) 2009 Michael Tindal
+#
+#   Copying and distribution of this file, with or without modification, are
+#   permitted in any medium without royalty provided the copyright notice
+#   and this notice are preserved. This file is offered as-is, without any
+#   warranty.
+
+#serial 14
+
+AC_DEFUN([AX_BOOST_THREAD],
+[
+	AC_ARG_WITH([boost-thread],
+	AS_HELP_STRING([--with-boost-thread@<:@=special-lib@:>@],
+                   [use the Thread library from boost - it is possible to specify a certain library for the linker
+                        e.g. --with-boost-thread=boost_thread-gcc-mt ]),
+        [
+        if test "$withval" = "no"; then
+			want_boost="no"
+        elif test "$withval" = "yes"; then
+            want_boost="yes"
+            ax_boost_user_thread_lib=""
+        else
+		    want_boost="yes"
+        	ax_boost_user_thread_lib="$withval"
+		fi
+        ],
+        [want_boost="yes"]
+	)
+
+	if test "x$want_boost" = "xyes"; then
+        AC_REQUIRE([AC_PROG_CC])
+        AC_REQUIRE([AC_CANONICAL_BUILD])
+		CPPFLAGS_SAVED="$CPPFLAGS"
+		CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
+		export CPPFLAGS
+
+		LDFLAGS_SAVED="$LDFLAGS"
+		LDFLAGS="$LDFLAGS $BOOST_LDFLAGS"
+		export LDFLAGS
+
+        AC_CACHE_CHECK(whether the Boost::Thread library is available,
+					   ax_cv_boost_thread,
+        [AC_LANG_PUSH([C++])
+			 CXXFLAGS_SAVE=$CXXFLAGS
+
+			 if test "x$build_os" = "xsolaris" ; then
+  				 CXXFLAGS="-pthreads $CXXFLAGS"
+			 elif test "x$build_os" = "xming32" ; then
+				 CXXFLAGS="-mthreads $CXXFLAGS"
+			 else
+				CXXFLAGS="-pthread $CXXFLAGS"
+			 fi
+			 AC_COMPILE_IFELSE(AC_LANG_PROGRAM([[@%:@include <boost/thread/thread.hpp>]],
+                                   [[boost::thread_group thrds;
+                                   return 0;]]),
+                   ax_cv_boost_thread=yes, ax_cv_boost_thread=no)
+			 CXXFLAGS=$CXXFLAGS_SAVE
+             AC_LANG_POP([C++])
+		])
+		if test "x$ax_cv_boost_thread" = "xyes"; then
+           if test "x$build_os" = "xsolaris" ; then
+			  BOOST_CPPFLAGS="-pthreads $BOOST_CPPFLAGS"
+		   elif test "x$build_os" = "xming32" ; then
+			  BOOST_CPPFLAGS="-mthreads $BOOST_CPPFLAGS"
+		   else
+			  BOOST_CPPFLAGS="-pthread $BOOST_CPPFLAGS"
+		   fi
+
+			AC_SUBST(BOOST_CPPFLAGS)
+
+			AC_DEFINE(HAVE_BOOST_THREAD,,[define if the Boost::Thread library is available])
+            BOOSTLIBDIR=`echo $BOOST_LDFLAGS | sed -e 's/@<:@^\/@:>@*//'`
+
+			LDFLAGS_SAVE=$LDFLAGS
+                        case "x$build_os" in
+                          *bsd* )
+                               LDFLAGS="-pthread $LDFLAGS"
+                          break;
+                          ;;
+                        esac
+            if test "x$ax_boost_user_thread_lib" = "x"; then
+                for libextension in `ls $BOOSTLIBDIR/libboost_thread*.so* 2>/dev/null | sed 's,.*/,,' | sed -e 's;^lib\(boost_thread.*\)\.so.*$;\1;'` `ls $BOOSTLIBDIR/libboost_thread*.a* 2>/dev/null | sed 's,.*/,,' | sed -e 's;^lib\(boost_thread.*\)\.a*$;\1;'`; do
+                     ax_lib=${libextension}
+				    AC_CHECK_LIB($ax_lib, exit,
+                                 [BOOST_THREAD_LIB="-l$ax_lib"; AC_SUBST(BOOST_THREAD_LIB) link_thread="yes"; break],
+                                 [link_thread="no"])
+  				done
+                if test "x$link_thread" != "xyes"; then
+                for libextension in `ls $BOOSTLIBDIR/boost_thread*.dll* 2>/dev/null | sed 's,.*/,,' | sed -e 's;^\(boost_thread.*\)\.dll.*$;\1;'` `ls $BOOSTLIBDIR/boost_thread*.a* 2>/dev/null | sed 's,.*/,,' | sed -e 's;^\(boost_thread.*\)\.a*$;\1;'` ; do
+                     ax_lib=${libextension}
+				    AC_CHECK_LIB($ax_lib, exit,
+                                 [BOOST_THREAD_LIB="-l$ax_lib"; AC_SUBST(BOOST_THREAD_LIB) link_thread="yes"; break],
+                                 [link_thread="no"])
+  				done
+                fi
+
+            else
+               for ax_lib in $ax_boost_user_thread_lib boost_thread-$ax_boost_user_thread_lib; do
+				      AC_CHECK_LIB($ax_lib, exit,
+                                   [BOOST_THREAD_LIB="-l$ax_lib"; AC_SUBST(BOOST_THREAD_LIB) link_thread="yes"; break],
+                                   [link_thread="no"])
+                  done
+
+            fi
+			if test "x$link_thread" = "xno"; then
+				AC_MSG_ERROR(Could not link against $ax_lib !)
+                        else
+                           case "x$build_os" in
+                              *bsd* )
+			        BOOST_LDFLAGS="-pthread $BOOST_LDFLAGS"
+                              break;
+                              ;;
+                           esac
+
+			fi
+		fi
+
+		CPPFLAGS="$CPPFLAGS_SAVED"
+    	LDFLAGS="$LDFLAGS_SAVED"
+	fi
+])
Index: src/Assert.cpp
===================================================================
--- src/Assert.cpp	(revision a80f4195d731fd366a976130725a3e131376108f)
+++ src/Assert.cpp	(revision a80f4195d731fd366a976130725a3e131376108f)
@@ -0,0 +1,212 @@
+/*
+ * Project: MoleCuilder
+ * Description: creates and alters molecular systems
+ * Copyright (C)  2010 University of Bonn. All rights reserved.
+ * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
+ */
+
+/*
+ * Assert.cpp
+ *
+ *  Created on: Mar 18, 2010
+ *      Author: crueger
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "MemDebug.hpp"
+
+#include "Assert.hpp"
+#include <iostream>
+
+using namespace std;
+
+namespace Assert{
+  AssertionFailure::AssertionFailure(std::string _condition,
+                                     std::string _file,
+                                     int _line,
+                                     std::string _message) :
+    condition(_condition),
+    file(_file),
+    line(_line),
+    message(_message)
+  {}
+
+  std::string AssertionFailure::getFile(){
+    return file;
+  }
+
+  int AssertionFailure::getLine(){
+    return line;
+  }
+
+  std::string AssertionFailure::getMessage(){
+    return message;
+  }
+
+  std::ostream& AssertionFailure::operator<<(std::ostream& out){
+    out << "Assertion \"" << condition << "\" failed in file " << file << " at line " << line << endl;
+    out << "Assertion Message: " << message << std::endl;
+    return out;
+  }
+
+  const char  ActionKeys[]  = {'\0','a','t','i'};
+  const char* ActionNames[] = {"Ask","Abort","Throw","Ignore"};
+}
+
+#ifndef NDEBUG
+
+#ifdef __GNUC__
+#include <cstdlib>
+#include <execinfo.h>
+#include <cxxabi.h>
+#endif
+
+Assert::Action Assert::_my_assert::defaultAction = Ask;
+std::vector<Assert::hook_t> Assert::_my_assert::hooks;
+
+std::map<std::string,bool> Assert::_wrapper::ignores;
+const char* Assert::_wrapper::message_ptr = "source pointer did not point to object of desired type";
+const char* Assert::_wrapper::message_ref = "source reference did not contain object of desired type";
+
+bool Assert::_my_assert::check(const char* condition,
+                               std::string message,
+                               const char* filename,
+                               const int line,
+                               bool& ignore)
+{
+  cout << "Assertion \"" << condition << "\" failed in file " << filename << " at line " << line << endl;
+  cout << "Assertion Message: " << message << std::endl;
+  while(true){
+    char choice;
+    if(defaultAction==Assert::Ask) {
+#ifdef __GNUC__
+      cout << "Please choose: (a)bort, (t)hrow execption, show (b)actrace, (i)gnore, al(w)ays ignore" << endl;
+#else
+      cout << "Please choose: (a)bort, (t)hrow execption, (i)gnore, al(w)ays ignore" << endl;
+#endif /* __GNUC__ */
+      cin >> choice;
+    }
+    else{
+      choice = ActionKeys[defaultAction];
+    }
+    switch(choice){
+      case 'a':
+        return true;
+        break;
+      case 't':
+        throw AssertionFailure(condition,filename,line,message);
+        break;
+#ifdef __GNUC__
+      case 'b':
+        Assert::_my_assert::backtrace(filename,line);
+       break;
+#endif /* __GNUC__ */
+      case 'w':
+        ignore = true;
+        // fallthrough
+      case 'i':
+        return false;
+        break;
+    }
+  }
+  return false;
+}
+
+#ifdef __GNUC__
+void Assert::_my_assert::backtrace(const char *file, int line){
+  const size_t max_depth = 100;
+  void* stack_addrs[max_depth];
+  size_t stack_depth;
+  char **stack_strings=0;
+  const char *func_name=0;
+  size_t sz = 64;
+
+  // get the backtrace
+  stack_depth   = ::backtrace(stack_addrs,max_depth);
+  stack_strings = backtrace_symbols(stack_addrs, stack_depth);
+  // used later for demangling
+  // reserved here, so we can free it unconditionally
+  char *dm_function = static_cast<char*>(malloc(sz));
+  if(!dm_function){
+    // malloc failed... we are out of luck
+    cout << "cannot provide stack trace due to exhausted memory" << endl;
+    return;
+  }
+
+  cout << "Backtrace from  " << file << "@" << line << ":" << endl;
+
+  // i=2 because we don't want this function, nor the assertion handler
+  for(unsigned int i=2;i<stack_depth-2;++i){
+    // find the mangled function name
+    char *begin = stack_strings[i];
+    // function name starts with a (
+    while(*begin && *begin!='(') ++begin;
+    char *end=begin;
+    while(*end && *end!='+') ++end;
+
+    // see if we found our function name
+    if(*begin && *end){
+      *begin++ = 0;
+      *end = 0;
+      // use the C++ demangler
+
+      int status;
+      char *func_ret = abi::__cxa_demangle(begin, dm_function, &sz, &status);
+      if(func_ret){
+        // abi might have realloced...
+        dm_function = func_ret;
+        func_name = dm_function;
+      }
+      else{
+        // demangling failed... get the function name without demangling
+        func_name = begin;
+      }
+    }
+    else{
+      // function name not found... get the whole line
+      func_name = stack_strings[i];
+    }
+    cout << func_name << endl;
+  }
+  free(dm_function);
+  free(stack_strings); // malloc()ed by backtrace_symbols
+}
+#endif /* __GNUC__ */
+
+void Assert::_my_assert::doHooks(){
+  for(vector<hook_t>::reverse_iterator iter = hooks.rbegin(); iter!=hooks.rend(); ++iter ){
+    (*iter)();
+  }
+}
+
+void Assert::_my_assert::addHook(hook_t hook){
+  hooks.push_back(hook);
+}
+
+void Assert::_my_assert::removeHook(Assert::hook_t hook){
+  for(vector<hook_t>::iterator iter = hooks.begin(); iter!=hooks.end();){
+    if((*iter)==hook){
+      iter = hooks.erase(iter);
+    }
+    else{
+      ++iter;
+    }
+  }
+}
+
+void Assert::_my_assert::setDefault(Assert::Action action){
+  defaultAction = action;
+}
+Assert::Action Assert::_my_assert::getDefault(){
+  return defaultAction;
+}
+std::string Assert::_my_assert::printDefault(){
+  return ActionNames[defaultAction];
+}
+
+#endif
+
Index: src/Assert.hpp
===================================================================
--- src/Assert.hpp	(revision a80f4195d731fd366a976130725a3e131376108f)
+++ src/Assert.hpp	(revision a80f4195d731fd366a976130725a3e131376108f)
@@ -0,0 +1,392 @@
+/*
+ * Assert.hpp
+ *
+ *  Created on: Mar 18, 2010
+ *      Author: crueger
+ */
+
+#ifndef ASSERT_HPP_
+#define ASSERT_HPP_
+
+#include<sstream>
+#include<string>
+#include<iosfwd>
+#include<vector>
+#include<map>
+
+#include "toString.hpp"
+
+/**
+ * \file Helpers/Assert.hpp
+ * <H1> ASSERT Howto </H1>
+ *
+ * <H2> Introduction </H2>
+ *
+ * ASSERT() is a small macro that allows easier debugging, when it is widely used. The custom
+ * ASSERT macro defined in this file works mainly the same way as the assert() macro that
+ * is defined in the Ansi-C standard, but includes a few nice additions.
+ *
+ * <H3> What ASSERT() does </H3>
+ *
+ * ASSERT can be used to make sure that a condition that always needs to be true for the code to
+ * work correctly is holding. If you have a function that takes a value greater than 0 and a value
+ * smaller than 0 indicates a mistake you should always do it the following way: <br>
+ * @code
+ * void foo(int a) // a should be greater 0
+ * {
+ *  ASSERT(a>0,"Parameter passed to foo was smaller than 0");
+ *  ...
+ * }
+ * @endcode
+ *
+ * (Note: some people say, that assertions like these should not be used to check function parameters.
+ * This is mainly due to the reason, that a failed assertion will show up inside the function. The buggy
+ * code however is at a completely different place, i.e. at the callers side. Always put the
+ * Assertions as close to the code that produces the value as possible, when looking at function
+ * parameters however this would mean, that any code calling foo would have an ASSERT(...) before
+ * it, which makes it easy to forget the Assertion at some places. Also this makes an easy example.)
+ *
+ * If the condition inside the ASSERT does not evaluate to true the user is shown a message, including
+ * the condition that failed, the line in which the failure was observed and the message of the assertion.
+ * In the above case that would look something like this:<br>
+ * @code
+ * Assertion "a>0" failed in foo.cpp in line 3.
+ * Assertion Message: Parameter passed to foo was smaller than 0
+ * @endcode
+ *
+ * In normal conditions, i.e. when no default action is set (see below for default actions) the user
+ * is then shown a short choice menu, on how to handle the assertion. The user can choose to abort the
+ * program, throw an exception of type AssertionFailure that contains the file, line and message,
+ * ignore the assertion or even to always ignore the assertion at that point (i.e. the ASSERT() macro
+ * at this file and line is fully disabled).
+ *
+ * Both ASSERT() and assert() handle debugging in the same way, i.e. they are only used when the
+ * NDEBUG macro is not defined. If the NDEBUG macro is defined, for example using a CXXFLAG then
+ * all asserts and ASSERTs will be disabled in the compiled program. That way in a end-user version
+ * all assertions can be removed with a single switch, thus not hassling the end-user with potential
+ * bugs.
+ *
+ * <H2> Special functions of ASSERT() </H2>
+ *
+ * Compared to the standard assert() macro the custom ASSERT() contains a few special functions. As
+ * first it is possible to set a global default behavior that is used anytime an assertion fails.
+ * This default behavior can be either of Assert::Ask, Assert::Abort, Assert::Throw or Assert::ignore.
+ * The default behavior is set using the ASSERT_DO() macro. For example if you want to check in a
+ * unittest that wrong code at another point actually makes a certain assert fail you could set
+ * ASSERT_DO(Assert::Throw) to make sure a exception is thrown and catch that exception using
+ * the CPPUNIT_ASSERT_THROW() macro. The current set default behavior can be queried as a string
+ * using the ASSERT_DEFAULT macro.
+ *
+ * As a second enhancement it is possible to install callback functions as hooks that will be executed
+ * when an assertion aborts the program. These callback functions could for example be used to flush
+ * any open streams, thus making sure files on the disk are not corrupted by a unexpected abortion.
+ * It would also be possible to install functions that produce some kind of "coredump" of important
+ * internal data-structures, thus giving the person looking for the bug some valuable information.
+ * These assertion hooks should however not be used to clean up the reserved memory of the program,
+ * because a) this memory is under normal circumstances reclaimed by the OS anyway, once the program
+ * has aborted and b) the memory might still contain some hints that could be useful when running
+ * the program inside a debugger and which could be destroyed by the clean-up. To use the hooking
+ * mechanism you can simply use the ASSERT_HOOK() macro, passing this macro any kind of void function.
+ * For example:<br/>
+ * @code
+ * void foo(){
+ *   // produce a coredump
+ *   ...
+ *   // close and flush all open handles
+ *   ...
+ * }
+ *
+ * int main(int argc, char **argv){
+ *   ASSERT_HOOK(foo);
+ *   ...
+ *   return 0;
+ * }
+ * @endcode
+ *
+ * All hooks will be executed in the reverse order of hooking, i.e. the function hooked last will be
+ * executed first when the abortion is handled. It is also possible to remove a hook to any function
+ * using the ASSERT_UNHOOK() macro and passing it the pointer to the function one wants to remove.
+ *
+ * Assertion hooks will only be executed when the program is terminated by an assertion using the
+ * abort mechanism. They will not be executed when the program exits in any other way. They also
+ * wont be executed when the assertion is ignored or an exception is thrown (even when the exception
+ * is not caught and thus terminates the program).
+ *
+ * <H2> Rules for using ASSERT() </H2>
+ *
+ * The rules for using ASSERT() are basically the same ones that can be used as guidlines for the
+ * standard assert() macro. So if you think you know those guidelines you can skip the following.
+ *
+ * <ul>
+ * <li> ASSERT() should be used only for problems that indicate a bug, i.e. problems that can be
+ * improved by rewriting parts of the program. ASSERT() should not be used to query problems that
+ * can go wrong during the normal execution of the program. For example ASSERT() should not be
+ * used to test whether a file could be opened, or memory could be reserved, as a failure of either
+ * of those tasks can not be improved upon by rewriting the code.
+ * <li> The condition in the ASSERT() macro should never contain any side-effects. Only call methods,
+ * when you are absolutely certain that these methods wont have any side-effects. Calling ASSERT()
+ * should in no way change the state of the program, because once the end-user version is produced
+ * using the NDEBUG flag all assertions are removed and so are the conditions. If the condition did
+ * cause a state transition, this state transition would be removed and the behavior of the end-user
+ * and the debug version might differ. Things you should watch out for are for example<br/>
+ * @code
+ * ASSERT(++i,"i was zero after incrementing");
+ * @endcode
+ * instead always do
+ * @code
+ * ++i;
+ * ASSERT(i,"i was zero after incrementing");
+ * @endcode
+ * <li> Give descriptive error messages. This one is a bit obvious but easy to do wrong, so I included
+ * it here. An
+ * @code
+ * ASSERT(ptr,"Pointer was zero");
+ * @endcode
+ * wont help anyone. If you do <br/>
+ * @code
+ * ASSERT(ptr,"Second argument of function foo should have pointed to an object of type bar, but was zero.");
+ * @endcode
+ * instead, people will almost immidiately know what to look for.
+ * </ul>
+ *
+ * <H2> Differences between ASSERT() and assert() </H2>
+ *
+ * This chapter is to explain why a custom ASSERT() macro was introduced and should be used in place
+ * of the standard assert(). Here are the main differences between ASSERT() and assert().
+ *
+ * <ul>
+ * <li> ASSERT() makes it easy to add a more verbose message about the nature of the failure. For
+ * assert() it has become customary to add messages using constructs like
+ * @code
+ * assert(c>0 && "Counter should be at least 1");
+ * @endcode in order to add descriptions. However both the syntax and the final output for this are
+ * a bit awkward. The custom ASSERT() handles messages in a much better way, as well as making them
+ * mandatory instead of optional.
+ * <li> ASSERT() leaves the user and the programmer a choice how to handle an assertion. While the
+ * assert() macro will always abort the program, the ASSERT() macro normally gives the user a choice on
+ * what to do. For debugging it might also be interesting how a broken assumption influences the rest
+ * of the program, so the assertion can also be ignored. Also the Exception mechanism allows
+ * assertions to be part of unittests, whereas they would always fail if the assert() macro was used.
+ * <li> ASSERT() does not unwind the stack (at least when compiled using gcc). The normal assert()
+ * exits the program, which unwinds the stack and destroys any hope for recovering a stack trace.
+ * ASSERT() on the other hand aborts the program using a special trap function, that leaves the
+ * stack intact. This way, when the program is run inside a debugger the stack is still available
+ * and can be inspected. This is the main reason, why it is safe to use ASSERT() to check function
+ * parameters, whereas assert() would give problems in such cases.
+ * <li> ASSERT() allows for hooks to be installed when the program exits. As mentioned above this
+ * makes it possible to produce coredumps, make sure all files are in a usable state or other tasks
+ * that have to be performed before killing the program.
+ * </ul>
+ *
+ * <H2> Tips and tricks and FAQ </H2>
+ *
+ * <ul>
+ * <li> <H4> How can I add values to the failure message of ASSERT(), e.g. I want to say that above "i"
+ *      failed to be zero, with i == ...?</H4>
+ * This can be done in the following way:
+ * @code
+ * ASSERT(!i,"i was not zero but "+toString(i)+"after incrementing");
+ * @endcode
+ * Note that this works because of the template function toString() (in src/Helpers/toString.hpp) that
+ * uses stringstreams to convert any value to std::string if the respective operator<< is implemented.
+ * <li> <H4> ASSERT() is broken. When I abort the program it says something about an
+ * "Illegal instruction"</H4>
+ * The complaints about the illegal instruction after an abortion are no need to worry. This
+ * illegal instruction is part of the trap that is used to exit the program while leaving the stack
+ * intact. This illegal instruction can be detected by the debugger, which means it will give you the
+ * usual prompt once it is encountered. The illegal instruction is guaranteed not to mess up anything,
+ * so there is no need to worry about it.
+ * <li> <H4> When compiling the program with $NON_GCC_COMPILER and then debugging it, it will
+ * unwind the stack. I need the backtrace however to find the bug </H4>
+ * The mechanism to preserve the stack is compiler specific. For now only a mechanism that is supported
+ * by gcc is implemented, because this compiler is widely used. For other compilers the program
+ * is simply exited, and the stack is destroyed. If you need a backtrace and you cannot use gcc you
+ * have to figure out a way to have your compiler produce a trap instruction in the program. You might
+ * want to use google to find out how to get your compiler to do that. For many compilers a
+ * _asm {int 3} is said to work. Also for VC++ the instruction __debugbreak() might produce a trap.
+ * Also dividing by zero is a hack that could be used as a last hope if you don't find a way to produce
+ * traps with your compiler even after a longer search. If you found a way to handle the traps you can
+ * then add the macro DEBUG_BREAK for your compiler and the stack will be preserved.
+ * <li> <H4> I have a portion of the program that should never be executed. How can I assure this
+ * using assert.</H4>
+ * This is a common task for assertions. For example you might have an exhaustive switch/case where
+ * the default value indicates that something went wrong. Simply use the following construct:
+ * @code
+ * switch(foo){
+ *   case Bar:
+ *     ...
+ *     break;
+ *   case Baz:
+ *     ...
+ *     break;
+ *   ...
+ *   default:
+ *     ASSERT(0,"This switch should always be exhaustive.\nDid somebody add values to the enum?");
+ * }
+ * @endcode
+  * </ul>
+ */
+
+#ifndef NDEBUG
+  #ifndef STRINGIFY
+    #define STRINGIFY(x) #x
+  #endif
+
+  #ifdef __GNUC__
+    // on gcc we know how to exit to the Debugger
+    #define DEBUG_BREAK __builtin_trap()
+  #else
+    #define DEBUG_BREAK exit(1)
+  #endif
+
+  #define ASSERT(condition,message) \
+    do{\
+      static bool ignore = false;\
+      if(!ignore){\
+        if(!(condition) && Assert::_my_assert::check(STRINGIFY(condition),(message),\
+                                                     __FILE__,__LINE__,ignore)){\
+          Assert::_my_assert::doHooks();\
+          DEBUG_BREAK;\
+        }\
+      } \
+    }while(0)
+
+  #define ASSERT_NOCATCH(message) \
+		catch(Assert::AssertionFailure&){throw;}\
+		catch(...){\
+		  static bool ignore = false; \
+		  if(!ignore){\
+			  if(Assert::_my_assert::check("Exception caught",(message),__FILE__,__LINE__,ignore)){\
+			    Assert::_my_assert::doHooks();\
+                            DEBUG_BREAK;\
+			  }\
+		  }\
+		} do{(void)(0);}while(0)
+
+  #define assert_cast Assert::_wrapper(__LINE__,__FILE__)._convert
+
+  #define ASSERT_DO(action)    do{Assert::_my_assert::setDefault(action);}while(0)
+  #define ASSERT_HOOK(hook)    do{Assert::_my_assert::addHook(hook);}while(0)
+  #define ASSERT_UNHOOK(hook)  do{Assert::_my_assert::removeHook(hook);}while(0)
+  #define ASSERT_DEFAULT       (Assert::_myAssert::printDefault())
+#else
+  // we need to do something, so this is the usual solution (e.g. assert.h)
+  #define ASSERT(condition,message) (void)(0)
+  #define ASSERT_NOCATCH(message)   catch(...) {throw;} do{(void)(0);}while(0)
+  #define assert_cast static_cast
+  #define ASSERT_DO(action)         (void)(0)
+  #define ASSERT_HOOK(hook)         (void)(0)
+  #define ASSERT_UNHOOK(hook)       (void)(0)
+  #define ASSERT_DEFAULT            std::string("Deactivated")
+#endif
+
+namespace Assert{
+
+  typedef void (*hook_t)(void);
+
+
+  enum Action {Ask,Abort,Throw,Ignore,MAX_ACTION};
+  extern const char  ActionKeys[MAX_ACTION];
+  extern const char* ActionNames[MAX_ACTION];
+
+  class AssertionFailure{
+  public:
+    AssertionFailure(std::string _condition, std::string _file, int _line, std::string _message);
+    std::string getFile();
+    int getLine();
+    std::string getMessage();
+
+    std::ostream& operator<<(std::ostream&);
+  private:
+    std::string condition;
+    std::string file;
+    int line;
+    std::string message;
+  };
+
+  //! @cond
+#ifndef NDEBUG
+    class _my_assert{
+    public:
+      static bool check(const char* condition,
+                        std::string message,
+                        const char* filename,
+                        const int line,
+                        bool& ignore);
+#ifdef __GNUC__
+      static void backtrace(const char *file, int line);
+#endif /* __GNUC__ */
+      static void addHook(Assert::hook_t hook);
+      static void removeHook(Assert::hook_t hook);
+      static void doHooks();
+      static void setDefault(Assert::Action);
+      static Assert::Action getDefault();
+      static std::string printDefault();
+    private:
+      static Assert::Action defaultAction;
+      static std::vector<Assert::hook_t> hooks;
+    };
+
+
+  class _wrapper{
+  public:
+    _wrapper(int _line,const char* _file) :
+      line(_line),
+      file(_file)
+      {}
+
+    // Overloaded template for pointers
+    template<typename target,typename source>
+    target _convert(source *src){
+      std::stringstream sstr;
+      sstr << file << ":" << line;
+      bool &ignore = ignores[sstr.str()];
+
+      if(!ignore){
+        bool res = dynamic_cast<target>(src)==static_cast<target>(src);
+        if(!res && _my_assert::check("type-safe typecast",message_ptr,file,line,ignore)){
+          _my_assert::doHooks();
+          DEBUG_BREAK;
+        }
+      }
+      return static_cast<target>(src);
+    }
+
+    // Overloaded template for references
+    template<typename target, typename source>
+    target _convert(source &src){
+            std::stringstream sstr;
+      sstr << file << ":" << line;
+      bool &ignore = ignores[sstr.str()];
+
+      try{
+        target res =dynamic_cast<target>(src);
+        return res;
+      }
+      catch(...){
+        if(!ignore){
+          if(_my_assert::check("type-safe typecast",message_ref,file,line,ignore)){
+            _my_assert::doHooks();
+            DEBUG_BREAK;
+          }
+        }
+      }
+      // The error was ignored. Just return whatever a static_cast would do
+      return static_cast<target>(src);
+    }
+  private:
+    int line;
+    const char *file;
+    static std::map<std::string,bool> ignores;
+    // this avoids duplication of the strings when templates are instantiated
+    static const char* message_ptr;
+    static const char* message_ref;
+  };
+#endif
+  //! @endcond
+}
+
+
+
+
+#endif /* ASSERT_HPP_ */
Index: src/Info.cpp
===================================================================
--- src/Info.cpp	(revision a80f4195d731fd366a976130725a3e131376108f)
+++ src/Info.cpp	(revision a80f4195d731fd366a976130725a3e131376108f)
@@ -0,0 +1,55 @@
+/*
+ * Project: MoleCuilder
+ * Description: creates and alters molecular systems
+ * Copyright (C)  2010 University of Bonn. All rights reserved.
+ * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
+ */
+
+/*
+ * Info.cpp
+ *
+ *  Created on: Nov 25, 2009
+ *      Author: heber
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "MemDebug.hpp"
+
+#include "Info.hpp"
+#include "Log.hpp"
+#include "Verbose.hpp"
+
+int Info::verbosity = 0;
+
+/**
+ * Constructor. Do not use this function. Use getInstance() instead.
+ *
+ * \return Info instance
+ */
+Info::Info(const char *msg) :
+  FunctionName(msg)
+{
+  verbosity++;
+  DoLog(0) && (Log() << Verbose(0) << "Begin of " << FunctionName << endl);
+};
+
+/**
+ * Destructor. Better use purgeInstance().
+ */
+Info::~Info() {
+  DoLog(0) && (Log() << Verbose(0) << "End of " << FunctionName << endl);
+  verbosity--;
+}
+
+/**
+ * Sets the verbosity.
+ *
+ * \param verbosityLevel verbosity
+ */
+void Info::setVerbosity(int verbosityLevel) {
+  verbosity = verbosityLevel;
+}
Index: src/Info.hpp
===================================================================
--- src/Info.hpp	(revision a80f4195d731fd366a976130725a3e131376108f)
+++ src/Info.hpp	(revision a80f4195d731fd366a976130725a3e131376108f)
@@ -0,0 +1,30 @@
+/*
+ * Info.hpp
+ *
+ *  Created on: Nov 25, 2009
+ *      Author: heber
+ */
+
+#ifndef INFO_HPP_
+#define INFO_HPP_
+
+using namespace std;
+
+/*********************************************** includes ***********************************/
+
+/****************************************** forward declarations *****************************/
+
+/********************************************** definitions *********************************/
+
+class Info {
+public :
+  static int verbosity;
+  const char *FunctionName;
+
+  Info(const char *msg);
+  ~Info();
+  static void setVerbosity(int verbosityLevel);
+
+};
+
+#endif /* INFO_HPP_ */
Index: src/Log.cpp
===================================================================
--- src/Log.cpp	(revision a80f4195d731fd366a976130725a3e131376108f)
+++ src/Log.cpp	(revision a80f4195d731fd366a976130725a3e131376108f)
@@ -0,0 +1,81 @@
+/*
+ * Project: MoleCuilder
+ * Description: creates and alters molecular systems
+ * Copyright (C)  2010 University of Bonn. All rights reserved.
+ * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
+ */
+
+/*
+ * log.cpp
+ *
+ *  Created on: Oct 19, 2009
+ *      Author: metzler
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "MemDebug.hpp"
+
+#include "logger.hpp"
+#include "errorlogger.hpp"
+
+/**
+ * Sets verbosity for the error logger and the standard logger.
+ *
+ * \param int verbosity level
+ */
+void setVerbosity(int verbosityLevel) {
+  logger::getInstance().setVerbosity(verbosityLevel);
+}
+
+/**
+ * Gets verbosity for the error logger and the standard logger.
+ *
+ * \param int verbosity level
+ */
+int getVerbosity() {
+  return logger::getInstance().getVerbosity();
+}
+
+/**
+ * Prints a log entry.
+ *
+ * \param indentation level of the message to log
+ */
+class logger& Log() {
+  return logger::getInstance();
+}
+
+/** Checks verbosity for logger.
+ * Is supposed to be used in construct as this:
+ * DoLog(2) && (Log() << Verbose(2) << "message." << endl);
+ * If DoLog does not return true, the right-hand side is not evaluated and we save some time.
+ * \param verbose verbosity level of this message
+ * \return true - print, false - don't
+ */
+bool DoLog(int verbose) {
+  return (verbose <= logger::getInstance().verbosity);
+}
+
+/** Checks verbosity for errorlogger.
+ * Is supposed to be used in construct as this:
+ * DoLog(2) && (Log() << Verbose(2) << "message." << endl);
+ * If DoLog does not return true, the right-hand side is not evaluated and we save some time.
+ * \param verbose verbosity level of this message
+ * \return true - print, false - don't
+ */
+bool DoeLog(int verbose) {
+  return (verbose <= errorLogger::getInstance().verbosity);
+}
+
+/**
+ * Prints an error log entry.
+ *
+ * \param indentation level of the message to log
+ */
+class errorLogger & eLog() {
+  return errorLogger::getInstance();
+}
Index: src/Log.hpp
===================================================================
--- src/Log.hpp	(revision a80f4195d731fd366a976130725a3e131376108f)
+++ src/Log.hpp	(revision a80f4195d731fd366a976130725a3e131376108f)
@@ -0,0 +1,21 @@
+/*
+ * log.hpp
+ *
+ *  Created on: Oct 19, 2009
+ *      Author: metzler
+ */
+
+#ifndef LOG_HPP_
+#define LOG_HPP_
+
+#include "errorlogger.hpp"
+#include "logger.hpp"
+
+class logger & Log();
+class errorLogger & eLog();
+void setVerbosity(int verbosityLevel);
+int getVerbosity();
+bool DoLog(int verbose);
+bool DoeLog(int verbose);
+
+#endif /* LOG_HPP_ */
Index: src/Makefile.am
===================================================================
--- src/Makefile.am	(revision a80f4195d731fd366a976130725a3e131376108f)
+++ src/Makefile.am	(revision a80f4195d731fd366a976130725a3e131376108f)
@@ -0,0 +1,70 @@
+# PLEASE adhere to the alphabetical ordering in this Makefile!
+# Also indentation by a single tab
+
+SUBDIRS = Patterns
+
+INCLUDES = -I$(top_srcdir)/src
+
+AM_LDFLAGS = $(CPPUNIT_LIBS) -ldl
+# Position-Independent Code necessary for shared library
+AM_CXXFLAGS = $(CPPUNIT_CFLAGS)
+AM_CPPFLAGS = ${BOOST_CPPFLAGS}
+
+# this includes source files that need to be present at multiple points
+HELPERSSOURCE =  \
+  Assert.cpp \
+  errorlogger.cpp \
+  Info.cpp \
+  Log.cpp \
+  logger.cpp \
+  MemDebug.cpp \
+  Verbose.cpp
+
+HELPERSHEADER =  \
+  Assert.hpp \
+  errorlogger.hpp \
+  Info.hpp \
+  Log.hpp \
+  logger.hpp \
+  MemDebug.hpp \
+  Verbose.hpp
+
+lib_LTLIBRARIES = libCodePatterns-@CODEPATTERNS_API_VERSION@.la
+libCodePatterns_includedir = $(includedir)/CodePatterns-$(CODEPATTERNS_API_VERSION)/
+nobase_libCodePatterns_include_HEADERS = ${HELPERSHEADER}
+
+## Define the source file list for the "libexample-@CODEPATTERNS_API_VERSION@.la"
+## target.  Note that @CODEPATTERNS_API_VERSION@ is not interpreted by Automake and
+## will therefore be treated as if it were literally part of the target name,
+## and the variable name derived from that.
+## The file extension .cc is recognized by Automake, and makes it produce
+## rules which invoke the C++ compiler to produce a libtool object file (.lo)
+## from each source file.  Note that it is not necessary to list header files
+## which are already listed elsewhere in a _HEADERS variable assignment.
+libCodePatterns_@CODEPATTERNS_API_VERSION@_la_SOURCES = ${HELPERSSOURCE}
+
+## Instruct libtool to include ABI version information in the generated shared
+## library file (.so).  The library ABI version is defined in configure.ac, so
+## that all version information is kept in one place.
+libCodePatterns_@CODEPATTERNS_API_VERSION@_la_LDFLAGS = -version-info $(CODEPATTERNS_SO_VERSION)
+
+## The generated configuration header is installed in its own subdirectory of
+## $(libdir).  The reason for this is that the configuration information put
+## into this header file describes the target platform the installed library
+## has been built for.  Thus the file must not be installed into a location
+## intended for architecture-independent files, as defined by the Filesystem
+## Hierarchy Standard (FHS).
+## The nodist_ prefix instructs Automake to not generate rules for including
+## the listed files in the distribution on 'make dist'.  Files that are listed
+## in _HEADERS variables are normally included in the distribution, but the
+## configuration header file is generated at configure time and should not be
+## shipped with the source tarball.
+libCodePatterns_libincludedir = $(libdir)/CodePatterns-$(CODEPATTERNS_API_VERSION)/include
+nodist_libCodePatterns_libinclude_HEADERS = $(top_builddir)/libCodePatterns_config.h
+
+## Install the generated pkg-config file (.pc) into the expected location for
+## architecture-dependent package configuration information.  Occasionally,
+## pkg-config files are also used for architecture-independent data packages,
+## in which case the correct install location would be $(datadir)/pkgconfig.
+pkgconfigdir = $(libdir)/pkgconfig
+pkgconfig_DATA = $(top_builddir)/CodePatterns-$(CODEPATTERNS_API_VERSION).pc
Index: src/MemDebug.cpp
===================================================================
--- src/MemDebug.cpp	(revision a80f4195d731fd366a976130725a3e131376108f)
+++ src/MemDebug.cpp	(revision a80f4195d731fd366a976130725a3e131376108f)
@@ -0,0 +1,552 @@
+/*
+ * Project: MoleCuilder
+ * Description: creates and alters molecular systems
+ * Copyright (C)  2010 University of Bonn. All rights reserved.
+ * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
+ */
+
+/*
+ * MemDebug.cpp
+ *
+ *  Created on: Apr 28, 2010
+ *      Author: crueger
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+// NDEBUG implies NO_MEMDEBUG
+#ifdef NDEBUG
+# ifndef NO_MEMDEBUG
+#   define NO_MEMDEBUG
+# endif
+#endif
+
+// NO_MEMDEBUG and MEMDEBUG are mutually exclusive, but at least one must be set
+#ifdef NO_MEMDEBUG
+# ifdef MEMDEBUG
+#   undef MEMDEBUG
+# endif
+#else
+# ifndef MEMDEBUG
+#   define MEMDEBUG
+# endif
+#endif
+
+#ifdef MEMDEBUG
+
+#include <iostream>
+#include <cstdlib>
+#include <cstring>
+#include <boost/thread.hpp>
+
+#ifdef __GNUC__
+#include <execinfo.h>
+#include <cxxabi.h>
+#endif
+
+using namespace std;
+
+// we need our own low level mutexex, since we cannot assure the time of construction and destruction
+// otherwise
+#if defined(unix) || defined(__unix)
+
+#include <pthread.h>
+#include <cassert>
+#define mutex_t    pthread_mutex_t
+#define mutex_init PTHREAD_MUTEX_INITIALIZER
+#define mutex_lock(mtx) \
+  do{\
+    int res = pthread_mutex_lock(&(mtx));\
+    assert(!res && "Could not lock mutex!");\
+  }while(0)
+
+#define mutex_unlock(mtx) \
+  do{\
+    int res = pthread_mutex_unlock(&(mtx));\
+    assert(!res && "Could not unlock mutex!");\
+  }while(0)
+
+#else
+# error "No thread structure defined for this plattform..."
+#endif
+
+namespace Memory {
+
+  // This struct is added before each memory chunk
+  // and contains tracking information. Anything used
+  // to track memory cannot use any dynamic memory, so
+  // we have to resort to classic C-idioms here.
+  // This struct also contains pointers to the next
+  // an previous chunks to allow fast traversion of
+  // all allocated memory blocks
+  struct entry_t {
+    typedef unsigned int checksum_t;
+    // we seperate the tracking info from the rest
+    // A checksum will be calculated for this part of
+    // the struct, so the information in here should
+    // not change during the lifetime of the memory
+    struct info_t {
+      enum {length = 64};
+      char file[length+1];
+      int line;
+#ifdef __GNUC__  // function tracking only works with GCC
+      // function names can get looooong
+      enum {length2 = 256};
+      char function[length2+1];
+#endif
+      size_t nbytes;
+      bool isUsed;
+      void *location;
+    } info;
+    bool isIgnored;
+    checksum_t checksum;
+    entry_t *prev;
+    entry_t *next;
+  };
+
+
+  mutex_t memorylock = mutex_init;
+
+  // start and end of the doubly-linked list
+  entry_t *begin=0;
+  entry_t *end=0;
+
+  // current amount of allocated memory
+  size_t state = 0;
+  // maximum amount of allocated memory
+  size_t max = 0;
+  // number of allocations that have been done so far
+  unsigned int allocs = 0;
+
+
+  // this sets the alignment of the returned memory block
+  // malloc guarantees an alignment at the 8 byte border,
+  // so we just do the same
+  const int alignment = 8;
+
+  // calculates a simple checksum for the info block
+  // the checksum is used to find memory corruptions
+  inline entry_t::checksum_t calcChecksum(entry_t::info_t *info){
+    char *buffer = (char*)info;
+    entry_t::checksum_t checksum =0;
+    for(size_t i=0;i<sizeof(entry_t::info_t);i++){
+      checksum+=buffer[i];
+    }
+    return checksum;
+  }
+
+  // gets the next alignet point which is greater than nbytes
+  // this function is only called a fixed number of times, so
+  // there is no need to optimize
+  inline size_t doAlign(size_t nbytes){
+    int nonaligned = nbytes % alignment;
+    if(nonaligned) {
+     return(nbytes - nonaligned + alignment);
+    }
+    else{
+      return nbytes;
+    }
+  }
+
+  // Output some state information
+  void getState(){
+    cout << "Maximum allocated Memory: " << max << " bytes" << endl;
+    cout << "Currently allocated Memory: " << state <<" bytes" << endl;
+    cout << allocs << " allocated chunks total" << endl;
+
+    // simple traversal of the chunk list
+    for(entry_t *pos=begin;pos;pos=pos->next){
+      cout << "\nChunk of " << pos->info.nbytes << " bytes" << " still available" << endl;
+#ifdef __GNUC__
+      cout << "Chunk reserved at: " << pos->info.function
+           << " (" << pos->info.file << ":" << pos->info.line  << ")" << endl;
+#else
+      cout << "Chunk reserved at: " << pos->info.file << ":" << pos->info.line << endl;
+#endif
+    }
+  }
+
+  void dumpMemory(std::ostream &ost){
+    ost << "Maximum allocated Memory: " << max << " bytes" << endl;
+    ost << "Maximum allocated Memory: " << max << " bytes" << endl;
+    ost << "Currently allocated Memory: " << state <<" bytes" << endl;
+    ost << allocs << " allocated chunks total" << endl;
+    bool corrupted=false;
+    for(entry_t *pos=begin;pos;pos=pos->next){
+      ost << "\nChunk of " << pos->info.nbytes << " bytes" << " still available" << endl;
+#     ifdef __GNUC__
+        ost << "Chunk reserved at: " << pos->info.function
+             << " (" << pos->info.file << ":" << pos->info.line  << ")" << endl;
+#     else
+        ost << "Chunk reserved at: " << pos->info.file << ":" << pos->info.line << endl;
+#     endif
+        ost << "Chunk address: " << pos->info.location << endl;
+        entry_t::checksum_t checksum = calcChecksum(&pos->info);
+        ost << "Checksum of chunk: " << checksum << endl;
+        ost << "Checksum at allocation time: " << pos->checksum << endl;
+        if(checksum!=pos->checksum){
+          ost << "!!!Chunk was corrupted!!!" << endl;
+          corrupted=true;
+        }
+    }
+    if(corrupted){
+      ost << "\n!!!Memory corruption detected!!!" << endl;
+    }
+  }
+
+  // Adds an entry to the linked list
+  void addEntry(entry_t *entry){
+    // check if the entry is already in the list
+    if(!entry->isIgnored)
+      return;
+
+    mutex_lock(Memory::memorylock);
+
+    entry->next=0;            // the created block is last in the list
+    entry->prev=Memory::end;  // the created block is last in the list
+    if(!Memory::begin){
+      // the list was empty... start a new one
+      Memory::begin=entry;
+    }
+    else {
+      // other blocks present... we can add to the last one
+      Memory::end->next=entry;
+    }
+    Memory::end=entry;
+
+    // update some global info
+    Memory::state  += entry->info.nbytes;
+    if(Memory::state>Memory::max){
+        Memory::max = Memory::state;
+    }
+    ++Memory::allocs;
+    // done with the list... it is safe to unlock now
+    mutex_unlock(Memory::memorylock);
+    entry->isIgnored = false;
+  }
+
+  // Deletes an entry from the linked list
+  void deleteEntry(entry_t *entry){
+    if(entry->isIgnored)
+      return;
+
+    mutex_lock(memorylock);
+    if(entry->prev){
+      entry->prev->next = entry->next;
+    }
+    else{
+      // this node was the beginning of the list
+      begin = entry->next;
+    }
+
+    if(entry->next){
+      entry->next->prev = entry->prev;
+    }
+    else{
+      // this node was the end of the list
+      end = entry->prev;
+    }
+    Memory::state  -= entry->info.nbytes;
+    mutex_unlock(memorylock);
+    entry->isIgnored = true;
+
+  }
+
+  void _ignore(void *ptr){
+    // just deletes the node from the list, but leaves the info intact
+    static const size_t entrySpace = Memory::doAlign(sizeof(Memory::entry_t));
+    entry_t *entry = (Memory::entry_t*)((char*)ptr-entrySpace);
+    deleteEntry(entry);
+  }
+
+#ifdef __GNUC__
+  // this function let's us find the caller's name
+  char* getCaller(){
+    // stack looks like this:
+    // getCaller();
+    // operator new();
+    // function_we_are_looking_for(); <-
+    const size_t max_depth = 3;
+    void* stack_addrs[max_depth];
+    size_t stack_depth;
+    char **stack_strings=0;
+    const char *func_name=0;
+    const char *toplevel = "Global scope";
+    char *retval=0;
+
+    // get the backtrace, depth three
+    stack_depth   = backtrace(stack_addrs,max_depth);
+    stack_strings = backtrace_symbols(stack_addrs, stack_depth);
+    // used later for demangling
+    // reserved here, so we can free it unconditionally
+    char *dm_function = static_cast<char*>(malloc(entry_t::info_t::length2));
+    if(!dm_function){
+      // malloc failed... we are out of luck
+      throw std::bad_alloc();
+    }
+
+    // see if we found our function name
+    if(stack_depth==max_depth){
+      // find the mangled function name
+      char *begin = stack_strings[max_depth-1];
+      // function name starts with a (
+      while(*begin && *begin!='(') ++begin;
+      char *end=begin;
+      while(*end && *end!='+') ++end;
+
+      // see if we found our function name
+      if(*begin && *end){
+        *begin++ = 0;
+        *end = 0;
+        // use the C++ demangler
+
+        size_t sz = entry_t::info_t::length2;
+        int status;
+        char *func_ret = abi::__cxa_demangle(begin, dm_function, &sz, &status);
+        if(func_ret){
+          // abi might have realloced...
+          dm_function = func_ret;
+          func_name = dm_function;
+        }
+        else{
+          // demangling failed... get the function name without demangling
+          func_name = begin;
+        }
+      }
+      else{
+        // function name not found... get the whole line
+        func_name = stack_strings[max_depth-1];
+      }
+
+    }
+    else{
+      func_name = toplevel;
+    }
+
+    // now we copy the desired function name
+    if((retval = static_cast<char*>(malloc(strlen(func_name)+1)))){
+      // we know that the string will fit, so strcpy is safe here
+      strcpy(retval,func_name);
+    }
+    else{
+      free(stack_strings); // malloc()ed by backtrace_symbols
+      free(dm_function);
+      // uh-uh ... seems we are out of luck for allocations now
+      throw std::bad_alloc();
+    }
+    free(dm_function);
+    free(stack_strings); // malloc()ed by backtrace_symbols
+    return retval;
+  }
+#endif
+}
+
+#ifdef __GNUC__
+
+void *operator new(size_t nbytes,const char* file, int line, const char* func) throw(std::bad_alloc) {
+
+  // to avoid allocations of 0 bytes if someone screws up
+  // allocation with 0 byte size are undefined behavior, so we are
+  // free to handle it this way
+  if(!nbytes) {
+    nbytes = 1;
+  }
+
+  // get the size of the entry, including alignment
+  static const size_t entrySpace = Memory::doAlign(sizeof(Memory::entry_t));
+
+  void *res;
+  if(!(res=malloc(entrySpace + nbytes))){
+    // new must throw, when space is low
+    throw std::bad_alloc();
+  }
+
+  // build the entry in front of the space
+  Memory::entry_t *entry = (Memory::entry_t*) res;
+  memset(res,0,entrySpace);
+  entry->info.nbytes = nbytes;
+  entry->info.isUsed = true;
+  strncpy(entry->info.file,file,Memory::entry_t::info_t::length);
+  entry->info.file[Memory::entry_t::info_t::length] = '\0';
+  entry->info.line=line;
+  strncpy(entry->info.function,func,Memory::entry_t::info_t::length2);
+  entry->info.function[Memory::entry_t::info_t::length2] = '\0';
+  // the space starts behind the info
+  entry->info.location = (char*)res + entrySpace;
+
+  // mark the block as not in the list (will be changed by addEntry)
+  entry->isIgnored = true;
+  if (line != 0)  { // indicator that we do not know the source
+    Memory::addEntry(entry);
+  }
+
+  // get the checksum...
+  entry->checksum = Memory::calcChecksum(&entry->info);
+
+  // ok, space is prepared... the user can have it.
+  // the rest (constructor, deleting when something is thrown etc)
+  // is handled automatically
+  return entry->info.location;
+}
+
+#else
+
+void *operator new(size_t nbytes,const char* file, int line) throw(std::bad_alloc) {
+
+  // to avoid allocations of 0 bytes if someone screws up
+  // allocation with 0 byte size are undefined behavior, so we are
+  // free to handle it this way
+  if(!nbytes) {
+    nbytes = 1;
+  }
+
+  // get the size of the entry, including alignment
+  static const size_t entrySpace = Memory::doAlign(sizeof(Memory::entry_t));
+
+  void *res;
+  if(!(res=malloc(entrySpace + nbytes))){
+    // new must throw, when space is low
+    throw std::bad_alloc();
+  }
+
+  // build the entry in front of the space
+  Memory::entry_t *entry = (Memory::entry_t*) res;
+  memset(res,0,entrySpace);
+  entry->info.nbytes = nbytes;
+  entry->info.isUsed = true;
+  strncpy(entry->info.file,file,Memory::entry_t::info_t::length);
+  entry->info.file[Memory::entry_t::info_t::length] = '\0';
+  entry->info.line=line;
+  // the space starts behind the info
+  entry->info.location = (char*)res + entrySpace;
+
+  // mark the block as not in the list (will be changed by addEntry)
+  entry->isIgnored = true;
+  if (line != 0)  { // indicator that we do not know the source
+    Memory::addEntry(entry);
+  }
+
+  // get the checksum...
+  entry->checksum = Memory::calcChecksum(&entry->info);
+  // this will be set to true, when the block is removed from
+  // the list for any reason
+  entry->isIgnored = false;
+
+  // ok, space is prepared... the user can have it.
+  // the rest (constructor, deleting when something is thrown etc)
+  // is handled automatically
+  return entry->info.location;
+}
+
+#endif
+
+void *operator new(size_t nbytes) throw(std::bad_alloc) {
+  // Just forward to the other operator, when we do not know from
+  // where the allocation came
+#ifdef __GNUC__
+  // this might throw bad_alloc
+  char *caller = Memory::getCaller();
+  void* retval = 0;
+
+  // if this throws, we have to clean up the caller anyway
+  try{
+    retval = operator new(nbytes,"Unknown",0,caller);
+  }
+  catch(...)
+  {
+    free(caller); // malloc()ed by Memory::getCaller();
+    throw;
+  }
+  free(caller); // malloc()ed by Memory::getCaller();
+  return retval;
+#else
+  return operator new(nbytes,"Unknown",0);
+#endif
+}
+
+#ifdef __GNUC__
+
+void *operator new[] (size_t nbytes,const char* file, int line, const char* func) throw(std::bad_alloc) {
+  // The difference between new and new[] is just for compiler bookkeeping.
+  return operator new(nbytes,file,line,func);
+}
+
+#else
+
+void *operator new[] (size_t nbytes,const char* file, int line) throw(std::bad_alloc) {
+  // The difference between new and new[] is just for compiler bookkeeping.
+  return operator new(nbytes,file,line);
+}
+
+#endif
+
+void *operator new[] (size_t nbytes) throw(std::bad_alloc) {
+  // Forward again
+#ifdef __GNUC__
+  // this might throw bad_alloc
+    char *caller = Memory::getCaller();
+    void *retval=0;
+
+    // if this throws, we have to clean up the caller anyway
+    try{
+      retval = operator new[] (nbytes,"Unknown",0,caller);
+    }
+    catch(...)
+    {
+      free(caller); // malloc()ed by Memory::getCaller();
+      throw;
+    }
+    free(caller); // malloc()ed by Memory::getCaller();
+    return retval;
+#else
+  return operator new[] (nbytes,"Unknown",0);
+#endif
+}
+
+void operator delete(void *ptr) throw() {
+  if(!ptr){
+    //cerr << "Warning: Deleting NULL pointer" << endl;
+    return;
+  }
+
+  // get the size for the entry, including alignment
+  static const size_t entrySpace = Memory::doAlign(sizeof(Memory::entry_t));
+
+  // get the position for the entry from the pointer the user gave us
+  Memory::entry_t *entry = (Memory::entry_t*)((char*)ptr-entrySpace);
+
+  // let's see if the checksum is still matching
+  if(Memory::calcChecksum(&entry->info)!=entry->checksum){
+    cerr << "Possible memory corruption detected!" << endl;
+    cerr << "Trying to recover allocation information..." << endl;
+    cerr << "Memory was allocated at " << entry->info.file << ":" << entry->info.line << endl;
+    terminate();
+  }
+
+  // this will destroy the checksum, so double deletes are caught
+  entry->info.isUsed = false;
+  Memory::deleteEntry(entry);
+
+  // delete the space reserved by malloc
+  free((char*)ptr-entrySpace);
+}
+
+// operator that is called when the constructor throws
+// do not call manually
+void operator delete(void *ptr,const char*, int) throw() {
+  operator delete(ptr);
+}
+
+void operator delete[](void *ptr){
+  // again difference between delete and delete[] is just in compiler bookkeeping
+  operator delete(ptr);
+}
+
+// and another operator that can be called when a constructor throws
+void operator delete[](void *ptr,const char*, int) throw(){
+  operator delete(ptr);
+}
+#endif
Index: src/MemDebug.hpp
===================================================================
--- src/MemDebug.hpp	(revision a80f4195d731fd366a976130725a3e131376108f)
+++ src/MemDebug.hpp	(revision a80f4195d731fd366a976130725a3e131376108f)
@@ -0,0 +1,121 @@
+/*
+ * MemDebug.hpp
+ *
+ *  Created on: Apr 28, 2010
+ *      Author: crueger
+ */
+
+#ifndef MEMDEBUG_HPP_
+#define MEMDEBUG_HPP_
+
+/**
+ * @file
+ * This module allows easy automatic memory tracking. Link this module to replace the
+ * operators new, new[], delete and delete[] with custom versions that add tracking
+ * information to allocated blocks.
+ *
+ * All tracking is done in O(1) for new and delete operators. Summaries for the
+ * used memory take O(N), where N is the number of currently allocated memory chunks.
+ *
+ * To use full tracking including file name and line number include this file in
+ * your sourcefiles.
+ */
+
+// Set all flags in a way that makes sense
+
+// NDEBUG implies NO_MEMDEBUG
+#ifdef NDEBUG
+# ifndef NO_MEMDEBUG
+#   define NO_MEMDEBUG
+# endif
+#endif
+
+// NO_MEMDEBUG and MEMDEBUG are mutually exclusive, but at least one must be set
+#ifdef NO_MEMDEBUG
+# ifdef MEMDEBUG
+#   undef MEMDEBUG
+# endif
+#else
+# ifndef MEMDEBUG
+#   define MEMDEBUG
+# endif
+#endif
+
+#ifdef MEMDEBUG
+
+#include <new>
+
+// some light header files, that do weird new stuff and therefore need
+// to be loaded before the define
+#include <string>
+#include <boost/optional.hpp>
+#include <boost/shared_ptr.hpp>
+#include <boost/function.hpp>
+
+
+namespace Memory {
+
+  /**
+   * Displays a short summary of the memory state.
+   */
+  void getState();
+  void dumpMemory(std::ostream&);
+
+  void _ignore(void*);
+
+  /**
+   * Use this to disable memory for a certain pointer on the heap.
+   * This is useful for pointers which should live over the run of the
+   * program, and which are deleted automatically at the end. Usually these
+   * pointers should be wrapped inside some kind of smart pointer to
+   * ensure destruction at the end.
+   */
+  template <typename T>
+  T *ignore(T* ptr){
+    _ignore((void*)ptr);
+    return ptr;
+  }
+}
+#ifdef __GNUC__
+void *operator new   (size_t nbytes,const char* file, int line, const char* func) throw(std::bad_alloc);
+void *operator new[] (size_t nbytes,const char* file, int line, const char* func) throw(std::bad_alloc);
+#else
+void *operator new   (size_t nbytes,const char* file, int line) throw(std::bad_alloc);
+void *operator new[] (size_t nbytes,const char* file, int line) throw(std::bad_alloc);
+#endif
+void operator delete   (void *ptr,const char*, int) throw();
+void operator delete[] (void *ptr,const char*, int) throw();
+
+
+
+/**
+ * This macro replaces all occurences of the keyword new with a replaced
+ * version that allows tracking.
+ */
+#ifdef __GNUC__
+#define new new(__FILE__,__LINE__,__PRETTY_FUNCTION__)
+#else
+#define new new(__FILE__,__LINE__)
+#endif
+
+#else
+
+#include <iosfwd>
+
+// memory debugging was disabled
+
+namespace Memory {
+  inline void getState(){};
+
+  inline void dumpMemory(std::ostream&){};
+
+  template <typename T>
+  inline T *ignore(T* ptr){
+    return ptr;
+  }
+}
+
+#endif
+
+
+#endif /* MEMDEBUG_HPP_ */
Index: src/Patterns/Cacheable.hpp
===================================================================
--- src/Patterns/Cacheable.hpp	(revision a80f4195d731fd366a976130725a3e131376108f)
+++ src/Patterns/Cacheable.hpp	(revision a80f4195d731fd366a976130725a3e131376108f)
@@ -0,0 +1,279 @@
+/*
+ * Cacheable.hpp
+ *
+ *  Created on: Feb 2, 2010
+ *      Author: crueger
+ */
+
+#ifndef CACHEABLE_HPP_
+#define CACHEABLE_HPP_
+
+#include "Patterns/Observer.hpp"
+#include <boost/function.hpp>
+#include <boost/shared_ptr.hpp>
+
+#include "Assert.hpp"
+
+#ifndef NO_CACHING
+
+  template<typename T>
+  class Cacheable : public Observer
+  {
+    // we define the states of the cacheable so we can do very fast state-checks
+    class State{
+    public:
+      State(Cacheable *_owner) :
+        busy(false),
+        owner(_owner)
+        {}
+      virtual T& getValue()=0;
+      virtual void invalidate()=0;
+      virtual bool isValid()=0;
+      virtual void enter()=0;
+      bool isBusy(){
+        return busy;
+      }
+    virtual std::string getName()=0;
+    protected:
+      bool busy;
+      Cacheable *owner;
+    };
+
+    class InvalidState : public State{
+    public:
+      InvalidState(Cacheable *_owner):
+        State(_owner)
+        {}
+
+      virtual T& getValue(){
+        // set the state to valid
+        State::owner->switchState(State::owner->validState);
+        // get the value from the now valid state
+        return State::owner->state->getValue();
+      }
+
+      virtual void invalidate(){
+        // nothing to do on this message
+      }
+
+      virtual bool isValid(){
+        return false;
+      }
+
+      virtual void enter(){
+        // nothing to do when entering this
+      }
+
+      virtual std::string getName(){
+        return "invalid";
+      }
+    };
+
+    class ValidState : public State{
+    public:
+      ValidState(Cacheable *_owner) :
+        State(_owner)
+        {}
+
+      virtual T& getValue(){
+        return content;
+      }
+
+      virtual void invalidate(){
+        State::owner->switchState(State::owner->invalidState);
+      }
+
+      virtual bool isValid(){
+        return true;
+      }
+
+      virtual void enter(){
+        State::busy= true;
+        // as soon as we enter the valid state we recalculate
+        content = State::owner->recalcMethod();
+        State::busy = false;
+      }
+
+      virtual std::string getName(){
+        return "valid";
+      }
+    private:
+      T content;
+    };
+
+    class DestroyedState : public State {
+    public:
+      DestroyedState(Cacheable *_owner) :
+        State(_owner)
+        {}
+
+      virtual T& getValue(){
+        ASSERT(0,"Cannot get a value from a Cacheable after it's Observable has died");
+        // we have to return a grossly invalid reference, because no value can be produced anymore
+        return *(static_cast<T*>(0));
+      }
+
+      virtual void invalidate(){
+        ASSERT(0,"Cannot invalidate a Cacheable after it's Observable has died");
+      }
+
+      virtual bool isValid(){
+        ASSERT(0,"Cannot check validity of a Cacheable after it's Observable has died");
+        return false;
+      }
+
+      virtual void enter(){
+        // nothing to do when entering this state
+      }
+
+      virtual std::string getName(){
+        return "destroyed";
+      }
+    };
+
+
+  typedef boost::shared_ptr<State> state_ptr;
+
+  public:
+    Cacheable(Observable *_owner, boost::function<T()> _recalcMethod, std::string name);
+    virtual ~Cacheable();
+
+    const bool isValid() const;
+    const T operator*() const;
+
+    // methods implemented for base-class Observer
+    void update(Observable *subject);
+    void subjectKilled(Observable *subject);
+  private:
+    void switchState(state_ptr newState);
+
+    mutable state_ptr state;
+    // pre-defined state so we don't have to construct to much
+    state_ptr invalidState;
+    state_ptr validState;
+    // destroyed state is not predefined, because we rarely enter that state and never leave
+
+    Observable *owner;
+    boost::function<T()> recalcMethod;
+
+    // de-activated copy constructor
+    Cacheable(const Cacheable&);
+  };
+
+
+  template<typename T>
+  Cacheable<T>::Cacheable(Observable *_owner, boost::function<T()> _recalcMethod, std::string name) :
+    Observer(name + "(Cached)"),
+    owner(_owner),
+    recalcMethod(_recalcMethod)
+  {
+    // create all states needed for this object
+    invalidState = state_ptr(new InvalidState(this));
+    validState = state_ptr(new ValidState(this));
+    state = invalidState;
+    // we sign on with the best(=lowest) priority, so cached values are recalculated before
+    // anybody else might ask for updated values
+    owner->signOn(this,-20);
+  }
+
+  // de-activated copy constructor
+  template<typename T>
+  Cacheable<T>::Cacheable(const Cacheable&){
+    ASSERT(0,"Cacheables should never be copied");
+  }
+
+  template<typename T>
+  const T Cacheable<T>::operator*() const{
+    // we can only use the cacheable when the owner is not changing at the moment
+    if(!owner->isBlocked()){
+      return state->getValue();
+    }
+    else{
+      return recalcMethod();
+    }
+  }
+
+  template<typename T>
+  Cacheable<T>::~Cacheable()
+  {
+    owner->signOff(this);
+  }
+
+  template<typename T>
+  const bool Cacheable<T>::isValid() const{
+    return state->isValid();
+  }
+
+  template<typename T>
+  void Cacheable<T>::update(Observable *subject) {
+    state->invalidate();
+  }
+
+  template<typename T>
+  void Cacheable<T>::subjectKilled(Observable *subject) {
+    state_ptr destroyed = state_ptr(new DestroyedState(this));
+    switchState(destroyed);
+  }
+
+  template<typename T>
+  void Cacheable<T>::switchState(state_ptr newState){
+    ASSERT(!state->isBusy(),"LOOP DETECTED: Cacheable state switched while recalculating.\nDid the recalculation trigger the Observable?");
+#ifdef LOG_OBSERVER
+    observerLog().addMessage() << "## Cacheable " << observerLog().getName(this) << " changed state (" << state->getName()
+                               << "->" << newState->getName() << ")" << std::endl;
+#endif
+    state = newState;
+    state->enter();
+  }
+
+#else
+  template<typename T>
+  class Cacheable : public Observer
+  {
+  public:
+    Cacheable(Observable *_owner, boost::function<T()> _recalcMethod,std::string name);
+    virtual ~Cacheable();
+
+    const bool isValid() const;
+    const T operator*() const;
+
+    // methods implemented for base-class Observer
+    void update(Observable *subject);
+    void subjectKilled(Observable *subject);
+  private:
+
+    boost::function<T()> recalcMethod;
+  };
+
+  template<typename T>
+  Cacheable<T>::Cacheable(Observable *_owner, boost::function<T()> _recalcMethod, std::string name) :
+    Observer(name),
+    recalcMethod(_recalcMethod)
+  {}
+
+  template<typename T>
+  const T Cacheable<T>::operator*() const{
+    return recalcMethod();
+  }
+
+  template<typename T>
+  Cacheable<T>::~Cacheable()
+  {}
+
+  template<typename T>
+  const bool Cacheable<T>::isValid() const{
+    return true;
+  }
+
+  template<typename T>
+  void Cacheable<T>::update(Observable *subject) {
+    ASSERT(0, "Cacheable::update should never be called when caching is disabled");
+  }
+
+  template<typename T>
+  void Cacheable<T>::subjectKilled(Observable *subject){
+    ASSERT(0, "Cacheable::subjectKilled should never be called when caching is disabled");
+  }
+#endif
+
+#endif /* CACHEABLE_HPP_ */
Index: src/Patterns/Makefile.am
===================================================================
--- src/Patterns/Makefile.am	(revision a80f4195d731fd366a976130725a3e131376108f)
+++ src/Patterns/Makefile.am	(revision a80f4195d731fd366a976130725a3e131376108f)
@@ -0,0 +1,14 @@
+nobase_include_HEADERS = $(PATTERNSOURCE) $(PATTERNHEADER)
+
+PATTERNSOURCE = \
+	ObservedContainer_impl.hpp \
+	Observer.cpp \
+	Registry_impl.hpp \
+	Singleton_impl.hpp
+PATTERNHEADER = \
+	Cacheable.hpp \
+	ObservedContainer.hpp \
+	ObservedIterator.hpp \
+	Observer.hpp \
+	Registry.hpp \
+	Singleton.hpp
Index: src/Patterns/Makefile.in
===================================================================
--- src/Patterns/Makefile.in	(revision a80f4195d731fd366a976130725a3e131376108f)
+++ src/Patterns/Makefile.in	(revision a80f4195d731fd366a976130725a3e131376108f)
@@ -0,0 +1,483 @@
+# Makefile.in generated by automake 1.11.1 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008, 2009  Free Software Foundation,
+# Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+subdir = src/Patterns
+DIST_COMMON = $(nobase_include_HEADERS) $(srcdir)/Makefile.am \
+	$(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/m4/ax_boost_base.m4 \
+	$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
+	$(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
+	$(top_srcdir)/m4/lt~obsolete.m4 \
+	$(top_srcdir)/m4/m4_ax_boost_thread.m4 \
+	$(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+	$(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/config.h \
+	$(top_builddir)/libCodePatterns_config.h
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+SOURCES =
+DIST_SOURCES =
+am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
+am__vpath_adj = case $$p in \
+    $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
+    *) f=$$p;; \
+  esac;
+am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
+am__install_max = 40
+am__nobase_strip_setup = \
+  srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
+am__nobase_strip = \
+  for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
+am__nobase_list = $(am__nobase_strip_setup); \
+  for p in $$list; do echo "$$p $$p"; done | \
+  sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
+  $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
+    if (++n[$$2] == $(am__install_max)) \
+      { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
+    END { for (dir in files) print dir, files[dir] }'
+am__base_list = \
+  sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
+  sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
+am__installdirs = "$(DESTDIR)$(includedir)"
+HEADERS = $(nobase_include_HEADERS)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AR = @AR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+BOOST_CPPFLAGS = @BOOST_CPPFLAGS@
+BOOST_LDFLAGS = @BOOST_LDFLAGS@
+BOOST_THREAD_LIB = @BOOST_THREAD_LIB@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CODEPATTERNS_API_VERSION = @CODEPATTERNS_API_VERSION@
+CODEPATTERNS_SO_VERSION = @CODEPATTERNS_SO_VERSION@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CPPUNIT_CFLAGS = @CPPUNIT_CFLAGS@
+CPPUNIT_CONFIG = @CPPUNIT_CONFIG@
+CPPUNIT_LIBS = @CPPUNIT_LIBS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DOXYGEN = @DOXYGEN@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+FGREP = @FGREP@
+GREP = @GREP@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAKEINFO = @MAKEINFO@
+MKDIR_P = @MKDIR_P@
+NM = @NM@
+NMEDIT = @NMEDIT@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+RANLIB = @RANLIB@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+STRIP = @STRIP@
+VERSION = @VERSION@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+lt_ECHO = @lt_ECHO@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+nobase_include_HEADERS = $(PATTERNSOURCE) $(PATTERNHEADER)
+PATTERNSOURCE = \
+	ObservedContainer_impl.hpp \
+	Observer.cpp \
+	Registry_impl.hpp \
+	Singleton_impl.hpp
+
+PATTERNHEADER = \
+	Cacheable.hpp \
+	ObservedContainer.hpp \
+	ObservedIterator.hpp \
+	Observer.hpp \
+	Registry.hpp \
+	Singleton.hpp
+
+all: all-am
+
+.SUFFIXES:
+$(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
+	@for dep in $?; do \
+	  case '$(am__configure_deps)' in \
+	    *$$dep*) \
+	      ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+	        && { if test -f $@; then exit 0; else break; fi; }; \
+	      exit 1;; \
+	  esac; \
+	done; \
+	echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/Patterns/Makefile'; \
+	$(am__cd) $(top_srcdir) && \
+	  $(AUTOMAKE) --gnu src/Patterns/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+	@case '$?' in \
+	  *config.status*) \
+	    cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+	  *) \
+	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+	esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure:  $(am__configure_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4):  $(am__aclocal_m4_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+
+mostlyclean-libtool:
+	-rm -f *.lo
+
+clean-libtool:
+	-rm -rf .libs _libs
+install-nobase_includeHEADERS: $(nobase_include_HEADERS)
+	@$(NORMAL_INSTALL)
+	test -z "$(includedir)" || $(MKDIR_P) "$(DESTDIR)$(includedir)"
+	@list='$(nobase_include_HEADERS)'; test -n "$(includedir)" || list=; \
+	$(am__nobase_list) | while read dir files; do \
+	  xfiles=; for file in $$files; do \
+	    if test -f "$$file"; then xfiles="$$xfiles $$file"; \
+	    else xfiles="$$xfiles $(srcdir)/$$file"; fi; done; \
+	  test -z "$$xfiles" || { \
+	    test "x$$dir" = x. || { \
+	      echo "$(MKDIR_P) '$(DESTDIR)$(includedir)/$$dir'"; \
+	      $(MKDIR_P) "$(DESTDIR)$(includedir)/$$dir"; }; \
+	    echo " $(INSTALL_HEADER) $$xfiles '$(DESTDIR)$(includedir)/$$dir'"; \
+	    $(INSTALL_HEADER) $$xfiles "$(DESTDIR)$(includedir)/$$dir" || exit $$?; }; \
+	done
+
+uninstall-nobase_includeHEADERS:
+	@$(NORMAL_UNINSTALL)
+	@list='$(nobase_include_HEADERS)'; test -n "$(includedir)" || list=; \
+	$(am__nobase_strip_setup); files=`$(am__nobase_strip)`; \
+	test -n "$$files" || exit 0; \
+	echo " ( cd '$(DESTDIR)$(includedir)' && rm -f" $$files ")"; \
+	cd "$(DESTDIR)$(includedir)" && rm -f $$files
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	mkid -fID $$unique
+tags: TAGS
+
+TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	set x; \
+	here=`pwd`; \
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	shift; \
+	if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
+	  test -n "$$unique" || unique=$$empty_fix; \
+	  if test $$# -gt 0; then \
+	    $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	      "$$@" $$unique; \
+	  else \
+	    $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	      $$unique; \
+	  fi; \
+	fi
+ctags: CTAGS
+CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	test -z "$(CTAGS_ARGS)$$unique" \
+	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+	     $$unique
+
+GTAGS:
+	here=`$(am__cd) $(top_builddir) && pwd` \
+	  && $(am__cd) $(top_srcdir) \
+	  && gtags -i $(GTAGS_ARGS) "$$here"
+
+distclean-tags:
+	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+	@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	list='$(DISTFILES)'; \
+	  dist_files=`for file in $$list; do echo $$file; done | \
+	  sed -e "s|^$$srcdirstrip/||;t" \
+	      -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+	case $$dist_files in \
+	  */*) $(MKDIR_P) `echo "$$dist_files" | \
+			   sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+			   sort -u` ;; \
+	esac; \
+	for file in $$dist_files; do \
+	  if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+	  if test -d $$d/$$file; then \
+	    dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+	    if test -d "$(distdir)/$$file"; then \
+	      find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+	    fi; \
+	    if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+	      cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+	      find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+	    fi; \
+	    cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+	  else \
+	    test -f "$(distdir)/$$file" \
+	    || cp -p $$d/$$file "$(distdir)/$$file" \
+	    || exit 1; \
+	  fi; \
+	done
+check-am: all-am
+check: check-am
+all-am: Makefile $(HEADERS)
+installdirs:
+	for dir in "$(DESTDIR)$(includedir)"; do \
+	  test -z "$$dir" || $(MKDIR_P) "$$dir"; \
+	done
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+	@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+	  install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+	  `test -z '$(STRIP)' || \
+	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+	-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+	-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+
+maintainer-clean-generic:
+	@echo "This command is intended for maintainers to use"
+	@echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libtool mostlyclean-am
+
+distclean: distclean-am
+	-rm -f Makefile
+distclean-am: clean-am distclean-generic distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am: install-nobase_includeHEADERS
+
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am:
+
+install-html: install-html-am
+
+install-html-am:
+
+install-info: install-info-am
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-pdf-am:
+
+install-ps: install-ps-am
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+	-rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-generic mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-nobase_includeHEADERS
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
+	clean-libtool ctags distclean distclean-generic \
+	distclean-libtool distclean-tags distdir dvi dvi-am html \
+	html-am info info-am install install-am install-data \
+	install-data-am install-dvi install-dvi-am install-exec \
+	install-exec-am install-html install-html-am install-info \
+	install-info-am install-man install-nobase_includeHEADERS \
+	install-pdf install-pdf-am install-ps install-ps-am \
+	install-strip installcheck installcheck-am installdirs \
+	maintainer-clean maintainer-clean-generic mostlyclean \
+	mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+	tags uninstall uninstall-am uninstall-nobase_includeHEADERS
+
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
Index: src/Patterns/ObservedContainer.hpp
===================================================================
--- src/Patterns/ObservedContainer.hpp	(revision a80f4195d731fd366a976130725a3e131376108f)
+++ src/Patterns/ObservedContainer.hpp	(revision a80f4195d731fd366a976130725a3e131376108f)
@@ -0,0 +1,95 @@
+/*
+ * AtomSet.hpp
+ *
+ *  Created on: Jul 8, 2010
+ *      Author: crueger
+ */
+
+#ifndef OBSERVEDCONTAINER_HPP_
+#define OBSERVEDCONTAINER_HPP_
+
+#include "types.hpp"
+
+#include <utility>
+#include "Patterns/ObservedIterator.hpp"
+#include "Descriptors/SelectiveIterator.hpp"
+
+class World;
+class atom;
+class AtomDescriptor;
+
+/**
+ * Forward to std::map<atomId_t,atom*> that allows production of observed and
+ * unobserved iterators to all atoms.
+ *
+ * Imported via typedef into class World. Defined here to avoid bloating of the
+ * World class
+ */
+template <class Container>
+class ObservedContainer
+{
+  friend class World;
+
+public:
+  typedef Container set_t;
+  // this iterator can be used for internal purposes...
+  // no lock used here
+  typedef typename set_t::iterator                              internal_iterator;
+  typedef typename std::reverse_iterator<internal_iterator>     reverse_internal_iterator;
+
+  // typedefs for iterator structure
+  typedef ObservedIterator<set_t>                               iterator;
+  typedef typename set_t::const_iterator                        const_iterator;
+  typedef std::reverse_iterator<iterator>                       reverse_iterator;
+  typedef typename std::reverse_iterator<const_iterator>        const_reverse_iterator;
+
+  // some more typedefs for STL-Structure
+  typedef typename set_t::key_type               key_type;
+  typedef typename set_t::mapped_type            mapped_type;
+  typedef typename set_t::value_type             value_type;
+  typedef typename set_t::key_compare            key_compare;
+  typedef typename set_t::allocator_type         allocator_type;
+
+  ObservedContainer(Observable*);
+  ObservedContainer(const ObservedContainer&);
+  virtual ~ObservedContainer();
+
+  // all the functions from STL-map (forwards to content)
+  ObservedContainer& operator=(const ObservedContainer&);
+
+  iterator                      begin();
+  const_iterator                begin()         const;
+  iterator                      end();
+  const_iterator                end()           const;
+  reverse_iterator              rbegin();
+  const_reverse_iterator        rbegin()        const;
+  reverse_iterator              rend();
+  const_reverse_iterator        rend()          const;
+
+  bool empty() const;
+  size_t size() const;
+  size_t max_size() const;
+
+  mapped_type &operator[](const key_type&);
+
+  std::pair<iterator,bool> insert (const value_type&);
+
+  size_t erase ( const key_type& x );
+  void clear();
+
+  iterator              find ( const key_type& x );
+  const_iterator        find ( const key_type& x ) const;
+
+  size_t count ( const key_type& x ) const;
+  internal_iterator             begin_internal();
+  internal_iterator             end_internal();
+  reverse_internal_iterator     rbegin_internal();
+  reverse_internal_iterator     rend_internal();
+
+  set_t &getContent();
+private:
+  set_t content;
+  Observable *obs;
+};
+
+#endif /* OBSERVEDCONTAINER_HPP_ */
Index: src/Patterns/ObservedContainer_impl.hpp
===================================================================
--- src/Patterns/ObservedContainer_impl.hpp	(revision a80f4195d731fd366a976130725a3e131376108f)
+++ src/Patterns/ObservedContainer_impl.hpp	(revision a80f4195d731fd366a976130725a3e131376108f)
@@ -0,0 +1,215 @@
+/*
+ * AtomSet_impl.hpp
+ *
+ *  Created on: Jul 8, 2010
+ *      Author: crueger
+ */
+
+#ifndef OBSERVEDCONTAINER_IMPL_HPP_
+#define OBSERVEDCONTAINER_IMPL_HPP_
+
+#include "Patterns/ObservedContainer.hpp"
+
+template <class Container>
+inline ObservedContainer<Container>::ObservedContainer(Observable* _obs) :
+  obs(_obs)
+{}
+
+template <class Container>
+inline ObservedContainer<Container>::ObservedContainer(const ObservedContainer<Container> &src) :
+  content(src.content),
+  obs(src.obs)
+{}
+
+template <class Container>
+inline ObservedContainer<Container>::~ObservedContainer()
+{}
+
+template <class Container>
+inline
+ObservedContainer<Container>&
+ObservedContainer<Container>::operator=(const ObservedContainer<Container> &rhs){
+  content=rhs.content;
+  return *this;
+}
+
+template <class Container>
+inline
+typename ObservedContainer<Container>::iterator
+ObservedContainer<Container>::begin(){
+  return ObservedContainer<Container>::iterator(content.begin(),obs);
+}
+
+template <class Container>
+inline
+typename ObservedContainer<Container>::const_iterator
+ObservedContainer<Container>::begin() const{
+  return content.begin();
+}
+
+template <class Container>
+inline
+typename ObservedContainer<Container>::iterator
+ObservedContainer<Container>::end(){
+  return ObservedContainer<Container>::iterator(content.end(),obs);
+}
+
+template <class Container>
+inline
+typename ObservedContainer<Container>::const_iterator
+ObservedContainer<Container>::end() const{
+  return content.end();
+}
+
+template <class Container>
+inline
+typename ObservedContainer<Container>::reverse_iterator
+ObservedContainer<Container>::rbegin(){
+  return reverse_iterator(begin());
+}
+
+template <class Container>
+inline
+typename ObservedContainer<Container>::const_reverse_iterator
+ObservedContainer<Container>::rbegin() const{
+  return const_reverse_iterator(begin());
+}
+
+template <class Container>
+inline
+typename ObservedContainer<Container>::reverse_iterator
+ObservedContainer<Container>::rend(){
+  return reverse_iterator(end());
+}
+
+template <class Container>
+inline
+typename ObservedContainer<Container>::const_reverse_iterator
+ObservedContainer<Container>::rend() const{
+  return const_reverse_iterator(end());
+}
+
+template <class Container>
+inline bool ObservedContainer<Container>::empty() const{
+  return content.empty();
+}
+
+template <class Container>
+inline size_t ObservedContainer<Container>::size() const{
+  return content.size();
+}
+
+template <class Container>
+inline size_t ObservedContainer<Container>::max_size() const{
+  return content.max_size();
+}
+
+template <class Container>
+inline
+typename ObservedContainer<Container>::mapped_type &
+ObservedContainer<Container>::operator[](const key_type &key){
+  return content[key];
+}
+
+template <class Container>
+inline
+std::pair<typename ObservedContainer<Container>::iterator,bool>
+ObservedContainer<Container>::insert (const value_type &value){
+  std::pair<typename set_t::iterator,bool> res = content.insert(value);
+  return std::make_pair(iterator(res.first,obs),res.second);
+}
+
+template <class Container>
+inline size_t ObservedContainer<Container>::erase ( const key_type& x ){
+  return content.erase(x);
+}
+
+template <class Container>
+inline void ObservedContainer<Container>::clear(){
+  content.clear();
+}
+
+template <class Container>
+inline
+typename ObservedContainer<Container>::iterator
+ObservedContainer<Container>::find ( const key_type& x ){
+  return iterator(content.find(x),obs);
+}
+
+template <class Container>
+inline
+typename ObservedContainer<Container>::const_iterator
+ObservedContainer<Container>::find ( const key_type& x ) const{
+  return content.find(x);
+}
+
+template <class Container>
+inline size_t ObservedContainer<Container>::count ( const key_type& x ) const{
+  return content.count(x);
+}
+
+/************ Unprotected access ***************/
+
+template <class Container>
+inline
+typename ObservedContainer<Container>::internal_iterator
+ObservedContainer<Container>::begin_internal(){
+  return content.begin();
+}
+
+template <class Container>
+inline
+typename ObservedContainer<Container>::internal_iterator
+ObservedContainer<Container>::end_internal(){
+  return content.end();
+}
+
+template <class Container>
+inline
+typename ObservedContainer<Container>::reverse_internal_iterator
+ObservedContainer<Container>::rbegin_internal(){
+  return content.rbegin();
+}
+
+template <class Container>
+inline
+typename ObservedContainer<Container>::reverse_internal_iterator
+ObservedContainer<Container>::rend_internal(){
+  return content.rend();
+}
+
+template <class Container>
+inline
+typename ObservedContainer<Container>::set_t &
+ObservedContainer<Container>::getContent(){
+  return content;
+}
+
+/************ Explicit instantiation ***************/
+
+#define CONSTRUCT_OBSERVEDCONTAINER(name) \
+    template ObservedContainer< name >& ObservedContainer< name >::operator=(const ObservedContainer< name >&); \
+    template ObservedContainer< name >::iterator ObservedContainer< name >::begin(); \
+    template ObservedContainer< name >::const_iterator ObservedContainer< name >::begin() const; \
+    template ObservedContainer< name >::iterator ObservedContainer< name >::end(); \
+    template ObservedContainer< name >::const_iterator ObservedContainer< name >::end() const; \
+    template ObservedContainer< name >::reverse_iterator ObservedContainer< name >::rbegin(); \
+    template ObservedContainer< name >::const_reverse_iterator ObservedContainer< name >::rbegin() const; \
+    template ObservedContainer< name >::reverse_iterator ObservedContainer< name >::rend(); \
+    template ObservedContainer< name >::const_reverse_iterator ObservedContainer< name >::rend() const; \
+    template bool ObservedContainer< name >::empty() const; \
+    template size_t ObservedContainer< name >::size() const; \
+    template size_t ObservedContainer< name >::max_size() const; \
+    template ObservedContainer< name >::mapped_type &ObservedContainer< name >::operator[](const key_type&); \
+    template std::pair<ObservedContainer< name >::iterator,bool> ObservedContainer< name >::insert (const value_type&); \
+    template size_t ObservedContainer< name >::erase ( const key_type& x ); \
+    template void ObservedContainer< name >::clear(); \
+    template ObservedContainer< name >::iterator ObservedContainer< name >::find ( const key_type& x ); \
+    template ObservedContainer< name >::const_iterator ObservedContainer< name >::find ( const key_type& x ) const; \
+    template size_t ObservedContainer< name >::count ( const key_type& x ) const; \
+    template ObservedContainer< name >::internal_iterator ObservedContainer< name >::begin_internal(); \
+    template ObservedContainer< name >::reverse_internal_iterator ObservedContainer< name >::rbegin_internal(); \
+    template ObservedContainer< name >::internal_iterator ObservedContainer< name >::end_internal(); \
+    template ObservedContainer< name >::reverse_internal_iterator ObservedContainer< name >::rend_internal(); \
+
+#endif /* OBSERVEDCONTAINER_IMPL_HPP_ */
Index: src/Patterns/ObservedIterator.hpp
===================================================================
--- src/Patterns/ObservedIterator.hpp	(revision a80f4195d731fd366a976130725a3e131376108f)
+++ src/Patterns/ObservedIterator.hpp	(revision a80f4195d731fd366a976130725a3e131376108f)
@@ -0,0 +1,150 @@
+/*
+ * ObservedIterator.hpp
+ *
+ *  Created on: Mar 4, 2010
+ *      Author: crueger
+ */
+
+#ifndef OBSERVEDITERATOR_HPP_
+#define OBSERVEDITERATOR_HPP_
+
+#include "Patterns/Observer.hpp"
+
+#include <iterator>
+
+// we build an iterator that observes traversion of some kind of Data structure conforming to STL
+template<class _Set>
+class ObservedIterator
+    : public std::iterator<typename std::iterator_traits<typename _Set::iterator>::iterator_category,
+                           typename std::iterator_traits<typename _Set::iterator>::value_type,
+                           typename std::iterator_traits<typename _Set::iterator>::difference_type,
+                           typename std::iterator_traits<typename _Set::iterator>::pointer,
+                           typename std::iterator_traits<typename _Set::iterator>::reference>
+{
+public:
+  // Some typedefs to conform to STL-Iterator structure
+  typedef typename _Set::iterator _Iter;
+  typedef typename _Iter::value_type value_type;
+  typedef typename _Iter::difference_type difference_type;
+  typedef typename _Iter::pointer pointer;
+  typedef typename _Iter::reference reference;
+  typedef typename _Iter::iterator_category iterator_category;
+
+  ObservedIterator() :
+    protector(0)
+  {}
+
+  ObservedIterator(_Iter iter,Observable *obs) :
+    iter(iter),
+    collection(obs),
+    protector(0)
+  {}
+
+  ObservedIterator(const ObservedIterator &dest) :
+    iter(dest.iter),
+    collection(dest.collection),
+    protector(dest.copyLock())
+  {}
+
+  ~ObservedIterator(){
+    if(protector)
+      delete protector;
+  }
+
+  // standard Iterator methods
+  ObservedIterator& operator=(const ObservedIterator& dest){
+    if(&dest !=this){
+      // get the new lock first, in case the two locks point to the same observable
+      Observable::_Observable_protector *newLock = dest.copyLock();
+      if(protector)
+        delete protector;
+      protector = newLock;
+      // After the new lock is aquired we can safely set the iterator
+      iter = dest.iter;
+      // we need to know the collection, in case we still have to set the lock
+      collection = dest.collection;
+    }
+    return *this;
+  }
+
+  ObservedIterator& operator++()   // prefix
+  {
+    ++iter;
+    return *this;
+  }
+
+  ObservedIterator operator++(int) // postfix with the dummy int parameter
+  {
+    ObservedIterator ret(*this);
+    ++(*this);
+    return ret;
+  }
+
+  ObservedIterator& operator--()   // prefix
+  {
+    --iter;
+    return *this;
+  }
+
+  ObservedIterator  operator--(int) // postfix with the dummy int parameter
+  {
+    ObservedIterator ret(*this);
+    --(*this);
+    return ret;
+  }
+
+  bool operator==(const ObservedIterator &rhs){
+    return iter==rhs.iter;
+  }
+
+  bool operator!=(const ObservedIterator &rhs){
+    return iter!=rhs.iter;
+  }
+
+  value_type operator*(){
+    // access is requested... time to get the lock
+    acquireLock();
+    return (*iter);
+  }
+
+  value_type *operator->(){
+    acquireLock();
+    return &(*iter);
+  }
+
+  // when we turn into a const iterator we can loose our lock
+  operator typename _Set::const_iterator() {
+    // typecast will be handled by the typecast method of the original iterator
+    return iter;
+  }
+
+private:
+
+  /**
+   * gets the lock for the collection when needed
+   *
+   * The lock is only acquired when the first change is done, so we can be free to do
+   * anything with the iterator before that. I.e. step forward, turn into a const_iterator
+   * etc.
+   */
+  void acquireLock(){
+    if(!protector)
+      protector = new Observable::_Observable_protector(collection);
+  }
+
+  Observable::_Observable_protector *copyLock() const{
+    // we only copy if we actually carry a lock
+    if(protector){
+      return new Observable::_Observable_protector(*protector);
+    }
+    else{
+      return 0;
+    }
+  }
+
+  _Iter iter;
+  Observable *collection;
+  Observable::_Observable_protector *protector;
+};
+
+#endif /* OBSERVEDITERATOR_HPP_ */
Index: src/Patterns/Observer.cpp
===================================================================
--- src/Patterns/Observer.cpp	(revision a80f4195d731fd366a976130725a3e131376108f)
+++ src/Patterns/Observer.cpp	(revision a80f4195d731fd366a976130725a3e131376108f)
@@ -0,0 +1,426 @@
+/*
+ * Project: MoleCuilder
+ * Description: creates and alters molecular systems
+ * Copyright (C)  2010 University of Bonn. All rights reserved.
+ * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
+ */
+
+/*
+ * Observer.cpp
+ *
+ *  Created on: Jan 19, 2010
+ *      Author: crueger
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "MemDebug.hpp"
+
+#include "Observer.hpp"
+
+#include <iostream>
+
+#include "Assert.hpp"
+#include "MemDebug.hpp"
+
+using namespace std;
+
+/****************** Static stuff for the observer mechanism ************/
+
+// All infrastructure for the observer-pattern is bundled at a central place
+// this is more efficient if many objects can be observed (inherit from observable)
+// but only few are actually coupled with observers. E.g. TMV has over 500.000 Atoms,
+// which might become observable. Handling Observerable infrastructure in each of
+// these would use memory for each atom. By handling Observer-infrastructure
+// here we only need memory for objects that actually are observed.
+// See [Gamma et al, 1995] p. 297
+
+map<Observable*, int> Observable::depth;  //!< Map of Observables to the depth of the DAG of Observers
+map<Observable*,multimap<int,Observer*> > Observable::callTable; //!< Table for each Observable of all its Observers
+std::map<Observable*,std::set<Notification*> > Observable::notifications;
+set<Observable*> Observable::busyObservables; //!< Set of Observables that are currently busy notifying their sign-on'ed Observers
+
+/** Attaching Sub-observables to Observables.
+ * Increases entry in Observable::depth for this \a *publisher by one.
+ *
+ * The two functions \sa start_observer_internal() and \sa finish_observer_internal()
+ * have to be used together at all time. Never use these functions directly
+ * START_OBSERVER and FINISH_OBSERVER also construct a bogus while(0) loop
+ * thus producing compiler-errors whenever only one is used.
+ * \param *publisher reference of sub-observable
+ */
+void Observable::start_observer_internal(Observable *publisher){
+  // increase the count for this observable by one
+  // if no entry for this observable is found, an new one is created
+  // by the STL and initialized to 0 (see STL documentation)
+#ifdef LOG_OBSERVER
+  observerLog().addMessage(depth[publisher]) << ">> Locking " << observerLog().getName(publisher) << endl;
+#endif
+  depth[publisher]++;
+}
+
+/** Detaching Sub-observables from Observables.
+ * Decreases entry in Observable::depth for this \a *publisher by one. If zero, we
+ * start notifying all our Observers.
+ *
+ * The two functions start_observer_internal() and finish_observer_internal()
+ * have to be used together at all time. Never use these functions directly
+ * START_OBSERVER and FINISH_OBSERVER also construct a bogus while(0) loop
+ * thus producing compiler-errors whenever only one is used.
+ * \param *publisher reference of sub-observable
+ */
+void Observable::finish_observer_internal(Observable *publisher){
+  // decrease the count for this observable
+  // if zero is reached all observed blocks are done and we can
+  // start to notify our observers
+  --depth[publisher];
+#ifdef LOG_OBSERVER
+  observerLog().addMessage(depth[publisher]) << "<< Unlocking " << observerLog().getName(publisher) << endl;
+#endif
+  if(depth[publisher]){}
+  else{
+    publisher->notifyAll();
+    // this item is done, so we don't have to keep the count with us
+    // save some memory by erasing it
+    depth.erase(publisher);
+  }
+}
+
+void Observable::enque_notification_internal(Observable *publisher, Notification_ptr notification){
+  ASSERT(notification->owner==publisher,"Some object tried to send a notification it does not own");
+  notifications[publisher].insert(notification);
+}
+
+/** Constructor for Observable Protector.
+ * Basically, calls start_observer_internal(). Hence use this class instead of
+ * calling the function directly.
+ *
+ * \param *protege Observable to be protected.
+ */
+Observable::_Observable_protector::_Observable_protector(Observable *_protege) :
+  protege(_protege)
+{
+  start_observer_internal(protege);
+}
+
+Observable::_Observable_protector::_Observable_protector(const _Observable_protector &dest) :
+    protege(dest.protege)
+{
+  start_observer_internal(protege);
+}
+
+/** Destructor for Observable Protector.
+ * Basically, calls finish_observer_internal(). Hence use this class instead of
+ * calling the function directly.
+ *
+ * \param *protege Observable to be protected.
+ */
+Observable::_Observable_protector::~_Observable_protector()
+{
+  finish_observer_internal(protege);
+}
+
+/************* Notification mechanism for observables **************/
+
+/** Notify all Observers of changes.
+ * Puts \a *this into Observable::busyObservables, calls Observer::update() for all in callee_t
+ * and removes from busy list.
+ */
+void Observable::notifyAll() {
+  // we are busy notifying others right now
+  // add ourselves to the list of busy subjects to enable circle detection
+  busyObservables.insert(this);
+  // see if anyone has signed up for observation
+  // and call all observers
+  try {
+    if(callTable.count(this)) {
+      // elements are stored sorted by keys in the multimap
+      // so iterating over it gives us a the callees sorted by
+      // the priorities
+      callees_t callees = callTable[this];
+      callees_t::iterator iter;
+      for(iter=callees.begin();iter!=callees.end();++iter){
+#ifdef LOG_OBSERVER
+        observerLog().addMessage() << "-> Sending update from " << observerLog().getName(this)
+                                   << " to " << observerLog().getName((*iter).second)
+                                   << " (priority=" << (*iter).first << ")"<< endl;
+#endif
+        (*iter).second->update(this);
+      }
+    }
+  }
+  ASSERT_NOCATCH("Exception thrown from Observer Update");
+
+  // send out all notifications that need to be done
+
+  notificationSet currentNotifications = notifications[this];
+  for(notificationSet::iterator it = currentNotifications.begin();
+      it != currentNotifications.end();++it){
+    (*it)->notifyAll();
+  }
+
+  notifications.erase(this);
+
+   // done with notification, we can leave the set of busy subjects
+  busyObservables.erase(this);
+}
+
+
+/** Handles passing on updates from sub-Observables.
+ * Mimicks basically the Observer::update() function.
+ *
+ * \param *publisher The \a *this we observe.
+ */
+void Observable::update(Observable *publisher) {
+  // circle detection
+  if(busyObservables.find(this)!=busyObservables.end()) {
+    // somehow a circle was introduced... we were busy notifying our
+    // observers, but still we are called by one of our sub-Observables
+    // we cannot be sure observation will still work at this point
+    ASSERT(0,"Circle detected in observation-graph.\n"
+             "Observation-graph always needs to be a DAG to work correctly!\n"
+             "Please check your observation code and fix this!\n");
+    return;
+  }
+  else {
+    // see if we are in the process of changing ourselves
+    // if we are changing ourselves at the same time our sub-observables change
+    // we do not need to publish all the changes at each time we are called
+    if(depth.find(this)==depth.end()) {
+#ifdef LOG_OBSERVER
+      observerLog().addMessage() << "-* Update from " << observerLog().getName(publisher)
+                                 << " propagated by " << observerLog().getName(this) << endl;
+#endif
+      notifyAll();
+    }
+    else{
+#ifdef LOG_OBSERVER
+      observerLog().addMessage() << "-| Update from " <<  observerLog().getName(publisher)
+                                 << " not propagated by " << observerLog().getName(this) << endl;
+#endif
+    }
+  }
+}
+
+/** Sign on an Observer to this Observable.
+ * Puts \a *target into Observable::callTable list.
+ * \param *target Observer
+ * \param priority number in [-20,20]
+ */
+void Observable::signOn(Observer *target,int priority) {
+  ASSERT(priority>=-20 && priority<=+20, "Priority out of range [-20:+20] when signing on Observer");
+#ifdef LOG_OBSERVER
+  observerLog().addMessage() << "@@ Signing on " << observerLog().getName(target) << " to " << observerLog().getName(this) << endl;
+#endif
+  bool res = false;
+  callees_t &callees = callTable[this];
+
+  callees_t::iterator iter;
+  for(iter=callees.begin();iter!=callees.end();++iter){
+    res |= ((*iter).second == target);
+  }
+  if(!res)
+    callees.insert(pair<int,Observer*>(priority,target));
+}
+
+/** Sign off an Observer from this Observable.
+ * Removes \a *target from Observable::callTable list.
+ * \param *target Observer
+ */
+void Observable::signOff(Observer *target) {
+  ASSERT(callTable.count(this),"SignOff called for an Observable without Observers.");
+#ifdef LOG_OBSERVER
+  observerLog().addMessage() << "** Signing off " << observerLog().getName(target) << " from " << observerLog().getName(this) << endl;
+#endif
+  callees_t &callees = callTable[this];
+
+  callees_t::iterator iter;
+  callees_t::iterator deliter;
+  for(iter=callees.begin();iter!=callees.end();) {
+    if((*iter).second == target) {
+      callees.erase(iter++);
+    }
+    else {
+      ++iter;
+    }
+  }
+  if(callees.empty()){
+    callTable.erase(this);
+  }
+}
+
+void Observable::signOn(Observer *target, Notification_ptr notification){
+  ASSERT(notification->owner==this,
+         "Trying to sign on for a notification that is not provided by this object");
+
+  notification->addObserver(target);
+}
+
+void Observable::signOff(Observer *target, Notification_ptr notification){
+  ASSERT(notification->owner==this,
+         "Trying to sign off from a notification that is not provided by this object");
+
+  notification->removeObserver(target);
+}
+
+bool Observable::isBlocked(){
+  return depth.count(this) > 0;
+}
+
+/** Handles sub-observables that just got killed
+ *  when an sub-observerable dies we usually don't need to do anything
+ *  \param *publisher Sub-Observable.
+ */
+void Observable::subjectKilled(Observable *publisher){
+}
+
+/** Constructor for class Observable.
+ */
+Observable::Observable(string name) :
+  Observer(Observer::BaseConstructor())
+{
+#ifdef LOG_OBSERVER
+  observerLog().addName(this,name);
+  observerLog().addMessage() << "++ Creating Observable " << observerLog().getName(this) << endl;
+#endif
+}
+
+/** Destructor for class Observable.
+ * When an observable is deleted, we let all our observers know. \sa Observable::subjectKilled().
+ */
+Observable::~Observable()
+{
+#ifdef LOG_OBSERVER
+  observerLog().addMessage() << "-- Destroying Observable " << observerLog().getName(this) << endl;
+#endif
+  if(callTable.count(this)) {
+    // delete all entries for this observable
+    callees_t callees = callTable[this];
+    callees_t::iterator iter;
+    for(iter=callees.begin();iter!=callees.end();++iter){
+      (*iter).second->subjectKilled(this);
+    }
+    callTable.erase(this);
+  }
+}
+
+/** Constructor for class Observer.
+ */
+Observer::Observer(string name)
+{
+#ifdef LOG_OBSERVER
+  observerLog().addName(this,name);
+  observerLog().addMessage() << "++ Creating Observer " << observerLog().getName(this) << endl;
+#endif
+}
+
+/**
+ * Base Constructor for class Observer
+ *
+ * only called from Observable Constructor
+ */
+Observer::Observer(Observer::BaseConstructor){
+#ifdef LOG_OBSERVER
+  observerLog().addObservable(this);
+#endif
+}
+
+/** Destructor for class Observer.
+ */
+Observer::~Observer()
+{
+#ifdef LOG_OBSERVER
+  if(!observerLog().isObservable(this)){
+    observerLog().addMessage() << "-- Destroying Observer " << observerLog().getName(this) << endl;
+  }
+#endif
+}
+
+/**
+ * Method for specialized notifications.
+ * Most Observers wont need or use this, so it is implemented
+ * empty in the base case;
+ */
+void Observer::recieveNotification(Observable *publisher, Notification_ptr notification){
+  ASSERT(0,"Notification received by object that did not sign on for it.");
+}
+
+Notification::Notification(Observable *_owner) :
+    owner(_owner)
+{}
+
+Notification::~Notification(){}
+
+void Notification::addObserver(Observer *target){
+  targets.insert(target);
+}
+
+void Notification::removeObserver(Observer *target){
+  targets.erase(target);
+}
+
+void Notification::notifyAll(){
+  for(std::set<Observer*>::iterator it=targets.begin();
+      it!=targets.end();++it){
+    (*it)->recieveNotification(owner,this);
+  }
+}
+
+#ifdef LOG_OBSERVER
+
+/************************* Methods to do logging of the Observer Mechanism *********/
+
+// The log needs to exist fairly early, so we make it construct on first use,
+// and never destroy it
+ObserverLog &observerLog(){
+  // yes, this memory is never freed... we need it around for the whole programm,
+  // so no freeing is possible
+  static ObserverLog *theLog = Memory::ignore(new ObserverLog());
+  return *theLog;
+}
+
+
+ObserverLog::ObserverLog() :
+  count (0)
+{}
+
+ObserverLog::~ObserverLog(){}
+
+string ObserverLog::getLog(){return log.str();}
+
+std::string ObserverLog::getName(void* obj){
+  return names[obj];
+}
+
+bool ObserverLog::isObservable(void* obj){
+  return observables.count(obj);
+}
+
+void ObserverLog::addName(void* obj , string name){
+  stringstream sstr;
+  sstr << name << "_" << count++;
+  names[obj] = sstr.str();
+}
+
+void ObserverLog::addObservable(void* obj){
+  observables.insert(obj);
+}
+
+void ObserverLog::deleteName(void* obj){
+  names.erase(obj);
+}
+
+void ObserverLog::deleteObservable(void* obj){
+  observables.erase(obj);
+}
+
+stringstream &ObserverLog::addMessage(int depth){
+  for(int i=depth;i--;)
+    log << "  ";
+  return log;
+}
+
+#endif
Index: src/Patterns/Observer.hpp
===================================================================
--- src/Patterns/Observer.hpp	(revision a80f4195d731fd366a976130725a3e131376108f)
+++ src/Patterns/Observer.hpp	(revision a80f4195d731fd366a976130725a3e131376108f)
@@ -0,0 +1,245 @@
+/*
+ * Observer.hpp
+ *
+ *  Created on: Jan 19, 2010
+ *      Author: crueger
+ */
+
+#ifndef OBSERVER_HPP_
+#define OBSERVER_HPP_
+
+#include <map>
+#include <set>
+#include <string>
+#include <sstream>
+
+/**
+ * Basic structure for the observer pattern
+ *
+ * Observers register themselves with the observables to be notified when something changes.
+ * In the Observable code that changes, attributes should be started with OBSERVE;. This macro
+ * locks the observer mechanism while changes are done. At the end of the scope in which the
+ * macro was placed the lock is released. When the last lock is released all changes are
+ * propagated to the observers.
+ *
+ * Each observerable can have sub-observables. When one of these sub-observables changes and
+ * notifies its observers the observable that contains them will also notify its observers.
+ * This passing on of updates is blocked, when the main-observable is in the process of
+ * updating many of its internal sub-observables. This means the update is not passed, if
+ * it is produced while the main-observable itself is within any Observation block.
+ */
+
+// Deactivate any logging when we are not in debug mode
+#ifdef NDEBUG
+#undef LOG_OBSERVER
+#endif
+
+class Observable;
+class Notification;
+
+// Pointers to notifications are used for unique identification
+// using this typedef makes it hard for others to mess up this
+// identification process
+typedef Notification *const Notification_ptr;
+
+template<class _Set>
+class ObservedIterator;
+
+/**
+ * An Observer is notified by all Observed objects, when anything changes.
+ *
+ * If a simple change is done to an Object the Obervable will call the update() method
+ * of all signed on observers, passing itself as a parameter for identification. The
+ * Observers should then react to the changes and update themselves accordingly.
+ *
+ * If an observed Object is destroyed it will call the subjectKilled() method
+ * of all signed on Observers, again passing itself as a parameter for identification.
+ * The Observers should handle the destruction of an observed Object gracefully, i.e.
+ * set themselves inactive, display something else, etc. There is no need
+ * to sign of from the dying object, since this will be handled by the Observable destructor.
+ */
+class Observer
+{
+  friend class Observable;
+  friend class Notification;
+  template<class> friend class ObservedIterator;
+
+  // indicates the constructor called from Observables
+  struct BaseConstructor{};
+
+public:
+  Observer(BaseConstructor);
+  Observer(std::string);
+  virtual ~Observer();
+
+protected:
+  /**
+   * This method is called upon changes of the Observable
+   */
+  virtual void update(Observable *publisher)=0;
+
+  /**
+   * This method is called when a special named change
+   * of the Observable occured
+   */
+  virtual void recieveNotification(Observable *publisher, Notification_ptr notification);
+
+  /**
+   * This method is called when the observed object is destroyed.
+   */
+  virtual void subjectKilled(Observable *publisher)=0;
+};
+
+/**
+ * An Observable implements all neccessary method for being observed.
+ *
+ * That is, it provides methods for signing on and of from an
+ * Observable that can be used by any observer. The actual
+ * observer-mechanism is handled at a central static place
+ * to avoid memory issues when many observable are around but only few
+ * are actually observed.
+ */
+class Observable : public Observer {
+public:
+  Observable(std::string _name);
+  virtual ~Observable();
+
+  /**
+   * Sign an Observer on to this Observable. The Observer will be notified
+   * whenever something inside the Observable changes. The Observer can
+   * assign itself a priority for the changes in the range of -20:+20.
+   * The Observer with lower priority will be called before the others,
+   * same as with Unix nice-levels. This can be used when an Object
+   * contains other objects that observe it (derived values), and these objects have
+   * to recalculate their states before the changes should be propageted to the
+   * UI. A default priority of 0 should be fine in most cases, since there is
+   * ussually no need to order the update sequence.
+   */
+  virtual void signOn(Observer *target, int priority=0);
+
+  /**
+   * Sign of a previously signed on Observer. After this no more
+   * updates will be recieved from that observer.
+   */
+  virtual void signOff(Observer *target);
+
+  /**
+   * Sign on for specialized notifications
+   */
+  virtual void signOn(Observer *target, Notification_ptr notification);
+
+  /**
+   * Stop receiving a specialized notification
+   */
+  virtual void signOff(Observer *target, Notification_ptr notification);
+
+  /**
+   * Ask an Observer if it is currently in a blocked state, i.e. if
+   * Changes are in Progress, that are not yet published.
+   */
+  virtual bool isBlocked();
+
+protected:
+  virtual void update(Observable *publisher);
+  virtual void subjectKilled(Observable *publisher);
+
+  virtual void notifyAll();
+protected:
+// Observer mechanism is done from a static central place
+  /**
+   * Internal method.
+   * Do not call directly. Use OBSERVE macro instead
+   */
+  static void start_observer_internal(Observable *publisher);
+  /**
+   * Internal method.
+   * Do not call directly. Use OBSERVE macro instead
+   */
+  static void finish_observer_internal(Observable *publisher);
+
+  static void enque_notification_internal(Observable *publisher, Notification_ptr notification);
+
+private:
+  typedef std::multimap<int,Observer*> callees_t;
+  typedef std::set<Notification*> notificationSet;
+  static std::map<Observable*, int> depth;
+  static std::map<Observable*,callees_t> callTable;
+  static std::map<Observable*,notificationSet> notifications;
+  static std::set<Observable*> busyObservables;
+
+  //! @cond
+  // Structure for RAII-Style notification
+public:
+  /**
+   * This structure implements the Observer-mechanism RAII-Idiom.
+   * It triggers certain functions on creation and destruction so that
+   * Observer mechanisms can be linked to scope block.
+   */
+  class _Observable_protector {
+  public:
+    _Observable_protector(Observable *);
+    _Observable_protector(const _Observable_protector&);
+    ~_Observable_protector();
+  private:
+    Observable *protege;
+  };
+  //! @endcond
+};
+
+class Notification {
+  friend class Observable;
+public:
+  Notification(Observable *_owner);
+  virtual ~Notification();
+protected:
+
+  void addObserver(Observer *target);
+  void removeObserver(Observer *target);
+
+  void notifyAll();
+private:
+  Observable * const owner;
+  std::set<Observer*> targets;
+};
+
+#ifdef LOG_OBSERVER
+
+/**
+ * This class is used to log the working of the observer mechanism
+ *
+ * TODO: make this conditional dependent on compiler Flag.
+ */
+class ObserverLog{
+  friend class Observable;
+  friend class Observer;
+  template <typename> friend class Cacheable;
+public:
+  ObserverLog();
+  ~ObserverLog();
+  std::string getLog();                        // get everything that has been logged
+  std::string getName(void*);                  // get the name of an actor
+  bool isObservable(void*);
+private:
+  int count;                                   // number to reference each actor in this framework
+  std::map<void*,std::string> names;           // List of names assigned to actors
+  std::set<void*> observables;                 // List of pointers to Observables. Needed to distinguish Observers and Observables
+  void addName(void*, std::string);            // Assign a name to an Actor
+  void addObservable(void*);
+  void deleteName(void*);                      // delete the name of an Actor
+  void deleteObservable(void*);
+  std::stringstream &addMessage(int depth=0);  // Add a Message to the logging
+  std::stringstream log;                       // The internal log object
+};
+
+ObserverLog &observerLog();
+
+#endif
+
+// extra macro is necessary to work with __LINE__
+#define PASTE(a,b) PASTE_HELPER(a,b)
+#define PASTE_HELPER(a,b) a ## b
+#define OBSERVE Observable::_Observable_protector PASTE(_scope_obs_protector_,__LINE__)(this)
+#define NOTIFY(notification) do{Observable::enque_notification_internal(this,notification);}while(0)
+#define LOCK_OBSERVABLE(observable) Observable::_Observable_protector PASTE(_scope_obs_protector_,__LINE__)(&(observable))
+
+#endif /* OBSERVER_HPP_ */
Index: src/Patterns/Registry.hpp
===================================================================
--- src/Patterns/Registry.hpp	(revision a80f4195d731fd366a976130725a3e131376108f)
+++ src/Patterns/Registry.hpp	(revision a80f4195d731fd366a976130725a3e131376108f)
@@ -0,0 +1,82 @@
+/*
+ * Registry.hpp
+ *
+ *  Based on initial ActionRegistry code by Till Crueger.
+ *
+ *  The registry pattern is basically just a singleton map, wherein instantiations
+ *  of a class can be registered, unregistered and retrieved.
+ *
+ *  Created on: Jul 28, 2010
+ *      Author: heber
+ */
+
+#ifndef REGISTRY_HPP_
+#define REGISTRY_HPP_
+
+#include <map>
+
+/**
+ * This template produces a generic registry pattern.
+ *
+ * <h1> Registry Howto </h1>
+ *
+ * The Registry is a class where instances of other classes are stored and be retrieved
+ * by a string token when desired. For this purpose a Registry should always be a singleton
+ * (i.e. use both this Registry and the Singleton pattern to declare a Registry class). It
+ * basically is simply a singleton container of a map, where the pointers to the class
+ * instances are stored by a string key and can be retrieved thereby.
+ *
+ * The available functions are as follows if your class instances to be stored in Registry
+ * are of type 'foo':
+ *
+ * - <code>foo* Registry<foo>::getByName()</code> : returns the instance of a specific
+ *    class foo instance as a pointer associated with the given name
+ * - <code>bool Registry<foo>::isPresentByName()</code> : returns whether an instance
+ *    of class foo is present under the given name.
+ * - <code>map<string,foo*>::iterator Registry<foo>::getBeginIter()</code> : returns an
+ *    iterator to the beginning of the storage map (STL).
+ * - <code>map<string,foo*>::const_iterator Registry<foo>::getBeginIter()</code> : returns a
+ *    constant iterator to the beginning of the storage map (STL).
+ * - <code>map<string,foo*>::const_iterator Registry<foo>::getEndIter()</code> : returns an
+ *    iterator to the one step past the last element of the storage map (STL).
+ * - <code>map<string,foo*>::const_iterator Registry<foo>::getEndIter()</code> : returns a
+ *    constant iterator to the one step past the last element of the storage map (STL).
+ *
+ * In order to use this pattern, additionally to the requirements of the Singleton pattern,
+ * do this:
+ *   -# in the declaration derive your class from Registry<foo>, where foo is the class to be
+ *      stored
+ *   -# in the definition add CONSTRUCT_REGISTRY(foo) to the code such that the templated
+ *      functions get instantiated there (otherwise you'll get undefined reference errors).
+ *
+ */
+
+template <class T>
+class Registry
+{
+public:
+  Registry();
+  ~Registry();
+
+  typedef typename std::map<const std::string,T*> instance_map;
+  typedef typename std::map<const std::string,T*>::iterator                  iterator;
+  typedef typename std::map<const std::string,T*>::const_iterator            const_iterator;
+
+  T* getByName(const std::string name) const;
+  bool isPresentByName(const std::string name) const;
+  void registerInstance(T*);
+  void unregisterInstance(T*);
+  void cleanup();
+
+  iterator getBeginIter();
+  const_iterator getBeginIter() const;
+  iterator getEndIter();
+  const_iterator getEndIter() const;
+
+private:
+  instance_map InstanceMap;
+};
+
+template <class T> std::ostream& operator<<(std::ostream& ost, const Registry<T>& m);
+
+#endif /* REGISTRY_HPP_ */
Index: src/Patterns/Registry_impl.hpp
===================================================================
--- src/Patterns/Registry_impl.hpp	(revision a80f4195d731fd366a976130725a3e131376108f)
+++ src/Patterns/Registry_impl.hpp	(revision a80f4195d731fd366a976130725a3e131376108f)
@@ -0,0 +1,150 @@
+/*
+ * Registry_impl.hpp
+ *
+ *  Created on: Jul 28, 2010
+ *      Author: heber
+ */
+
+#ifndef REGISTRY_IMPL_HPP_
+#define REGISTRY_IMPL_HPP_
+
+#include "MemDebug.hpp"
+
+#include "Patterns/Registry.hpp"
+#include "Patterns/Singleton_impl.hpp"
+
+#include "Assert.hpp"
+#include <iostream>
+
+/** Constructor for class Registry.
+ */
+template <class T> Registry<T>::Registry()
+{}
+
+/** Destructor for class Registry.
+ */
+template <class T> Registry<T>::~Registry()
+{}
+
+/** Returns pointer to an instance named by \a name.
+ * \param name name of instance
+ * \return pointer to instance
+ */
+template <class T> T* Registry<T>::getByName(const std::string name) const
+{
+  typename std::map<const std::string,T*>::const_iterator iter;
+  iter = InstanceMap.find(name);
+  ASSERT(iter!=InstanceMap.end(),"Query for an instance "+name+" not stored in registry");
+  return iter->second;
+}
+
+/** States whether instance is present or not.
+ * \note This is needed as Registry<T>::getByName() ASSERT()s that instance is in std::map.
+ * \param name name of instance
+ * \return true - present, false - instance absent
+ */
+template <class T>bool Registry<T>::isPresentByName(const std::string name) const
+{
+  typename std::map<const std::string,T*>::const_iterator iter;
+  iter = InstanceMap.find(name);
+  return iter!=InstanceMap.end();
+}
+
+/** Registers an instance with the Registry.
+ * \param *instance pointer to T.
+ */
+template <class T>void Registry<T>::registerInstance(T* instance){
+  std::pair<typename std::map<const std::string,T*>::iterator,bool> ret;
+  //std::cout << "Trying to register instance of type " << typeid(T).name() << " with name " << instance->getName() << "." << std::endl;
+  ret = InstanceMap.insert(typename std::pair<const std::string,T*>(instance->getName(),instance));
+  ASSERT(ret.second,"Two instances with the same name "+instance->getName()+" added to registry");
+}
+
+/** Unregisters an instance.
+ * \param *instance pointer to instance.
+ */
+template <class T>void Registry<T>::unregisterInstance(T* instance){
+  //std::cout << "Unregistering instance of type " << typeid(T).name() << " with name " << instance->getName() << "." << std::endl;
+  InstanceMap.erase(instance->getName());
+}
+
+/** Removes every instance from the registry.
+ */
+template <class T>void Registry<T>::cleanup()
+{
+  typename std::map<const std::string,T*>::iterator iter;
+  for(iter=InstanceMap.begin();iter!=InstanceMap.end();++iter) {
+    //std::cerr << "Removing instance "+iter->first+" from registry" << std::endl;
+    delete iter->second;
+  }
+  InstanceMap.clear();
+}
+
+
+/** Returns an iterator pointing to the start of the std::map of instance's.
+ * \return begin iterator
+ */
+template <class T>
+typename std::map<const std::string,T*>::iterator Registry<T>::getBeginIter()
+{
+  return InstanceMap.begin();
+}
+
+/** Returns an iterator pointing to the end of the std::map of instance's.
+ * \return end iterator
+ */
+template <class T>
+typename std::map<const std::string,T*>::iterator Registry<T>::getEndIter()
+{
+  return InstanceMap.end();
+}
+
+/** Returns a const iterator pointing to the start of the std::map of instance's.
+ * \return constant begin iterator
+ */
+template <class T>
+typename std::map<const std::string,T*>::const_iterator Registry<T>::getBeginIter() const
+{
+  return InstanceMap.begin();
+}
+
+/** Returns a const iterator pointing to the end of the std::map of instance's.
+ * \return constant end iterator
+ */
+template <class T>
+typename std::map<const std::string,T*>::const_iterator Registry<T>::getEndIter() const
+{
+  return InstanceMap.end();
+}
+
+/** Prints the contents of the Registry \a &m to \a &ost.
+ * \param &ost output stream
+ * \param &m reference to Registry
+ * \return reference to the above out stream for concatenation
+ */
+template <class T>
+std::ostream& operator<<(std::ostream& ost, const Registry<T>& m)
+{
+  ost << "Registry contains:" << std::endl;
+  for (typename std::map<const std::string,T*>::const_iterator iter = m.getBeginIter(); iter != m.getEndIter(); ++iter) {
+    ost << "\t" << iter->first << " with pointer " << iter->second << std::endl;
+  }
+  return ost;
+};
+
+/**
+ * This define allows simple instantiation of the necessary registryfunctions
+ * at a chosen place.
+ */
+#define CONSTRUCT_REGISTRY(InstanceType) \
+    template InstanceType* Registry<InstanceType>::getByName(const std::string) const; \
+    template bool Registry<InstanceType>::isPresentByName(const std::string) const; \
+    template void Registry<InstanceType>::registerInstance(InstanceType*); \
+    template void Registry<InstanceType>::unregisterInstance(InstanceType*); \
+    template std::map<const std::string,InstanceType*>::iterator Registry<InstanceType>::getBeginIter(); \
+    template std::map<const std::string,InstanceType*>::const_iterator Registry<InstanceType>::getBeginIter() const; \
+    template std::map<const std::string,InstanceType*>::iterator Registry<InstanceType>::getEndIter(); \
+    template std::map<const std::string,InstanceType*>::const_iterator Registry<InstanceType>::getEndIter() const;
+
+
+#endif /* REGISTRY_IMPL_HPP_ */
Index: src/Patterns/Singleton.hpp
===================================================================
--- src/Patterns/Singleton.hpp	(revision a80f4195d731fd366a976130725a3e131376108f)
+++ src/Patterns/Singleton.hpp	(revision a80f4195d731fd366a976130725a3e131376108f)
@@ -0,0 +1,278 @@
+/*
+ * Singleton.hpp
+ *
+ *  Created on: Mar 10, 2010
+ *      Author: crueger
+ */
+
+#ifndef SINGLETON_HPP_
+#define SINGLETON_HPP_
+
+#include <boost/thread.hpp>
+
+#include "Assert.hpp"
+
+/**
+ * This template produces the generic singleton pattern using the CRTP idiom.
+ *
+ * <h1> Singleton Howto </h1>
+ * <h2> Introduction </h2>
+ *
+ * A Singleton is a class of which there can only be a single Object in the programm. It is
+ * described as an design-pattern in Gof:96 (the famous design-pattern book). In the
+ * molecuilder there are so far several Singletons serving a wide range of purposes:
+ *
+ * - the World, which handles all atoms, molecules and bonds
+ * - the ActionRegistry, which stores all created actions by name for later use
+ * - the UIFactory, which is an AbstractFactory (another design-pattern from Gof:96) and
+ *   handles all creation of gui elements to ensure a single type throughout the programm
+ * - the logger and errorLogger classes, that can be used to output messages on the screen
+ *   depending on certain conditions
+ *
+ * Because those classes can only be instantiated once you cannot simply call <code>new World()</code>
+ * or <code>delete</code> on them. Rather they have to be constructed and accessed using the singleton
+ * mechanism. This mechanism consists of four static functions (and a fifth that is used internally,
+ * but we will get to that later). These functions are:
+ *
+ * - <code>Singleton& Singleton::getInstance()</code> : returns the instance of the singleton as
+ *    a reference
+ * - <code>Singleton* Singleton::getPointer()</code> : returns the instance of the singleton as a
+ *    pointer
+ * - <code>void Singleton::purgeInstance()</code> : destroys the single Instance of the singleton
+ * - <code>Singleton& Singleton::resetInstance()</code> : resets the Singleton, i.e. destroys the
+ *    old instance and creates a new one
+ *
+ * If you need the instance of the singleton it is usually fine just to use one off the accessor
+ * functions (i.e. <code>getInstance()</code> or <code>getPointer()</code>. Any creation of the
+ * Singleton is then handled by these functions, so that the same object will be returned whenever
+ * one of these functions is called. This easy process is true for most singletons you will need
+ * to use. The only special singleton is the UIFactory.
+ *
+ * <h3>Special functions of the UIFactory</h3>
+ *
+ * If you simply call the <code>getInstance()</code> method of the UIFactory class the program
+ * will crash. This happens, because the UIFactory in itself is abstract and needs to know what
+ * kind of user interface it should produce later on. You need to tell the class the type of UI
+ * using the void <code>UIFactory::makeUserInterface(InterfaceTypes type)</code> method. This will
+ * also take care of creating the sole instance, so that the accessor functions will work afterwards.
+ * What this also means is, that you cannot <code>reset()</code> the UIFactory, because at that
+ * point it wont know anymore what to construct. A sequence of <code>UIFactory::purgeInstance()</code>,
+ * <code>UIFactory::makeUserInterface()</code> and <code>UIFactory::getInstance()</code> will work
+ * though.
+ *
+ * In order to make life easier and propagate changes to the singleton mechanism to all those
+ * classes, there is a simple framework class that can be used to make any other class a
+ * singleton through inheritance. This class can be found in the Pattern directory.
+ *
+ * <h2>How to make a class Singleton</h2>
+ *
+ * Most of the time you will only need singletons that don't require additional
+ * information for creation. So I will cover the basic case for constructing singletons
+ * first and then explain what has to be changed to make it accept special parameters.
+ * Singletons are created by inheriting from the <code>Singleton<class T></code> template
+ * using the Curiously recurring template pattern (CRTP). What this means is, that the
+ * class they inherit from carries the inheriting class as a template parameter. For example
+ * <code>class MySingletonExaple : public Singleton<MySingletonExample>{...}</code>. If you
+ * want to know more about this idiom have a look at the
+ * <A HREF="http://en.wikipedia.org/wiki/Curiously_recurring_template_pattern">wikipedia
+ * page for this idiom</A>, but don't worry if you don't quite get how this works for now, for
+ * the use of the singleton framework this is not important.
+ *
+ * If you want to make a class a singleton you can use the following sequence of steps.
+ *
+ * - Inherit from the singleton pattern using the CRTP as above:<br>
+ *   @code
+ *     class MySingletonExaple : public Singleton<MySingletonExample>{ ...}
+ *   @endcode
+ * - Make constructor and destructor private to avoid creation or destruction from
+ *   outside the class:<br>
+ *    @code
+ *      class MySingletonExaple : public Singleton<MySingletonExample>{
+ *        private:
+ *          MySingletonExample();
+ *          ~MySingletonExample();
+ *      ...}
+ *    @endcode
+ * - give the inherited class access to the class internals using a friend declaration:<br>
+ *    @code
+ *       class MySingletonExaple : public Singleton<MySingletonExample>{
+ *         friend class Singleton<MySingletonExample>; // don't forget the template parameters here
+ *         private:
+ *           MySingletonExample();
+ *           ~MySingletonExample();
+ *       ...}
+ *    @endcode
+ *
+ * - include the file "Patterns/Singleton_impl.hpp" that carries the implementation details of
+ *   the singleton functions in your implementation file of the class.
+ * - make the compiler construct the template instantiations. For this you can use the defined
+ *   keyword <code>CONSTRUCT_SINGLETON(name)</code> at any toplevel point in the implementation
+ *   file:<br>
+ *    @code
+ *       void MySingletonExample::foo(){...}
+ *       void MySingletonExample::bar(){...}
+ *       CONSTRUCT_SINGLETON(MySingletonExample) // no ; after this
+ *     @endcode
+ *
+ * <h3>Singleton with initialization parameters</h3>
+ *
+ * Sometimes it is necessary for a singleton to be passed some initilization parameters. For
+ * example the UIFactory mentioned above needs to know what kind of user interface it has to
+ * produce. Making a singleton that takes initialization parameters is only sligtly different
+ * from the steps lined out above. Here are all the differences:
+ *
+ * - pass an extra <code>false</code> to the template to deactivate the standard instantiation
+ *   mechanism
+ * - write a method that handles the special parameters and instantiation. In this method you
+ *   can use the <code>setInstance(T*)</code> method inherited from the singleton pattern to set
+ *   the created instance. The <code>setInstance()</code> method will only work when the
+ *   <code>false<code> template parameter has been set and produce errors otherwise.
+ *
+ */
+template <class T, bool _may_create=true>
+class Singleton
+{
+private:
+  /**
+   * simple auto_ptr that is used by Singleton template
+   *
+   * This ptr_t allows destruction of the object using a private destructor,
+   * when only the Singleton pattern is friend with the class
+   *
+   * All methods have similar sematics to auto_ptr
+   */
+  class ptr_t {
+  public:
+    ptr_t();
+    ptr_t(T* _content);
+    ~ptr_t();
+    T& operator*();
+    T* get();
+    void reset(T* _content);
+    void reset();
+    ptr_t& operator=(const ptr_t& rhs);
+  private:
+    mutable T* content;
+  };
+
+  /**
+   * This object handles the actual creation inside the singleton
+   *
+   * Using template specialization this will allways know what it can
+   * do or cannot do at compile time
+   */
+  template<class creator_T, bool creator_may_create>
+  struct creator_t {
+    inline static creator_T* make();
+    inline static void set(creator_T*&,creator_T*);
+  };
+
+  // specialization to allow fast creations
+
+  /**
+   * Specialized template that allows automatic construction only
+   */
+  template<class creator_T>
+  struct creator_t<creator_T,true>{
+    inline static creator_T* make(){
+      return new creator_T();
+    }
+
+    inline static void set(creator_T*&,creator_T*){
+      ASSERT(0, "Cannot set the Instance for a singleton of this type");
+    }
+  };
+
+  /**
+   * specialized template that allows setting only
+   */
+  template<class creator_T>
+  struct creator_t<creator_T,false>{
+    inline static creator_T* make(){
+      ASSERT(0, "Cannot create a singleton of this type directly");
+      return 0;
+    }
+    inline static void set(ptr_t& dest,creator_T* src){
+      dest.reset(src);
+    }
+  };
+
+  // this is used for creation
+  typedef creator_t<T,_may_create> creator; //< the creator used
+
+public:
+  // make the state of this singleton accessible
+  static const bool may_create=_may_create; //!< the type of singleton that we have
+
+  /**
+   * returns the instance of this Singleton as a reference
+   *
+   * If no Singleton exists at this point and we are allowed to create one
+   * a new one is created and stored inside the singleton
+   *
+   * If no automatic creation is allowed, make sure to create an instance first
+   * using the appropriate methods of the derived class. Otherwise this method
+   * would fail.
+   */
+  static T& getInstance();
+
+  /**
+   * returns the instance of this singleton as a pointer
+   *
+   * If no Singleton exists at this point and we are allowed to create one
+   * a new one is created and stored inside the singleton.
+   *
+   * If no automatic creation is allowed, make sure to create an instance first
+   * using the appropriate methods of the derived class. Otherwise this method
+   * would fail.
+   */
+  static T* getPointer();
+
+  /**
+   * destroys the current instance of this singleton
+   */
+  static void purgeInstance();
+
+  /**
+   * destroys the current instance of the singleton and immidiately constructs
+   * a new one. Similar to using <code>purgeInstance()</code> and <code>getInstance()</code>
+   * but plays more nicely when observers are present. Especially the new instance is created
+   * before the old one is destroyed so observers can switch their targets, when they are notified
+   * of the destruction.
+   *
+   * If no automatic creation is allowed this method wont work.
+   */
+  static T&   resetInstance();
+
+protected:
+  /**
+   * Method used to set the instance, when no automatic creation is allowed.
+   *
+   * Call this after the instantiation method in the derived class has created
+   * it's instance and want's the singleton mechanism to keep it around for later
+   * use.
+   *
+   * This method will always fail when automatic creation is enabled.
+   */
+  static void setInstance(T*);
+
+
+  /**
+   * empty constructor to allow creation of subclases
+   */
+  Singleton();
+
+private:
+  /**
+   * the copy constructor is private to avoid accidental copying of Singletons, for example
+   * when passing singletons to functions by value instead of by reference. If you
+   * need copying of singletons call the default constructor in the copy constructor
+   * of the derived object. The copyied object wont be known to the singleton mechanism.
+   */
+  Singleton(const Singleton&);
+
+  static boost::recursive_mutex instanceLock; //!< a lock for the pointer of the instance
+  static ptr_t theInstance; //!< the actual instance of the singleton
+};
+
+#endif /* SINGLETON_HPP_ */
Index: src/Patterns/Singleton_impl.hpp
===================================================================
--- src/Patterns/Singleton_impl.hpp	(revision a80f4195d731fd366a976130725a3e131376108f)
+++ src/Patterns/Singleton_impl.hpp	(revision a80f4195d731fd366a976130725a3e131376108f)
@@ -0,0 +1,143 @@
+/*
+ * Singleton_impl.hpp
+ *
+ *  Created on: Mar 10, 2010
+ *      Author: crueger
+ */
+
+#ifndef SINGLETON_IMPL_HPP_
+#define SINGLETON_IMPL_HPP_
+
+#include "Assert.hpp"
+#include "Patterns/Singleton.hpp"
+
+/****** Static instance Variables of the template *******/
+
+template <class T,bool _may_create>
+typename Singleton<T,_may_create>::ptr_t Singleton<T,_may_create>::theInstance(0);
+
+template <class T,bool _may_create>
+boost::recursive_mutex Singleton<T,_may_create>::instanceLock;
+
+/****** templates singleton creation and destruction functions ******/
+
+template <class T,bool _may_create>
+T& Singleton<T,_may_create>::getInstance(){
+  // boost supports RAII-Style locking, so we don't need to unlock
+  boost::recursive_mutex::scoped_lock guard(instanceLock);
+  if(!theInstance.get()) {
+    theInstance.reset(creator::make());
+  }
+  return *theInstance;
+}
+
+template <class T,bool _may_create>
+T* Singleton<T,_may_create>::getPointer(){
+  // boost supports RAII-Style locking, so we don't need to unlock
+  boost::recursive_mutex::scoped_lock guard(instanceLock);
+  if(!theInstance.get()) {
+    theInstance.reset(creator::make());
+  }
+  return theInstance.get();
+
+}
+
+template <class T,bool _may_create>
+void Singleton<T,_may_create>::purgeInstance(){
+  // boost supports RAII-Style locking, so we don't need to unlock
+  boost::recursive_mutex::scoped_lock guard(instanceLock);
+  theInstance.reset();
+}
+
+template <class T,bool _may_create>
+T& Singleton<T,_may_create>::resetInstance(){
+  ptr_t oldInstance;
+  {
+    // boost supports RAII-Style locking, so we don't need to unlock
+    boost::recursive_mutex::scoped_lock guard(instanceLock);
+
+    oldInstance = theInstance;
+    theInstance.reset(creator::make());
+    // oldworld does not need protection any more,
+    // since we should have the only reference
+
+    // worldLock handles access to the pointer,
+    // not to the object
+  } // scope-end releases the lock
+
+  // oldInstance goes out of scope at the End of this function. The carried object will then be destroyed by the auto_ptr
+  return *theInstance;
+}
+
+
+template <class T,bool _may_create>
+void Singleton<T,_may_create>::setInstance(T* newInstance){
+  ASSERT(!theInstance.get(), "Trying to set the instance of an already created singleton");
+  boost::recursive_mutex::scoped_lock guard(instanceLock);
+  theInstance.reset(newInstance);
+}
+
+template<class T, bool _may_create>
+Singleton<T,_may_create>::Singleton(){/* empty */}
+
+// private copy constructor to avoid unintended copying
+template <class T, bool _may_create>
+Singleton<T,_may_create>::Singleton(const Singleton<T,_may_create>&){
+  ASSERT(0, "Copy constructor of singleton template called");
+}
+
+/**
+ * This define allows simple instantiation of the necessary singleton functions
+ * at a chosen place.
+ */
+#define CONSTRUCT_SINGLETON(name) \
+    template name& Singleton< name , name::may_create >::getInstance(); \
+    template name* Singleton< name , name::may_create >::getPointer();  \
+    template void  Singleton< name , name::may_create >::purgeInstance(); \
+    template name& Singleton< name , name::may_create >::resetInstance(); \
+    template void  Singleton< name , name::may_create >::setInstance( name* );
+
+/************ Internal Pointer Wrapper to allow automatic purging *************/
+
+template <class T,bool _may_create>
+Singleton<T,_may_create>::ptr_t::ptr_t() :
+content(0){};
+
+template <class T,bool _may_create>
+Singleton<T,_may_create>::ptr_t::ptr_t(T* _content) :
+content(_content){};
+
+template <class T,bool _may_create>
+Singleton<T,_may_create>::ptr_t:: ~ptr_t()
+{delete content;};
+
+template <class T,bool _may_create>
+T& Singleton<T,_may_create>::ptr_t::operator*()
+{return *content;};
+
+template <class T,bool _may_create>
+T* Singleton<T,_may_create>::ptr_t::get()
+{return content;};
+
+template <class T,bool _may_create>
+void Singleton<T,_may_create>::ptr_t::reset(T* _content){
+  delete content;
+  content = _content;
+}
+
+template <class T,bool _may_create>
+void Singleton<T,_may_create>::ptr_t::reset()
+{reset(0);}
+
+template <class T,bool _may_create>
+typename Singleton<T,_may_create>::ptr_t& Singleton<T,_may_create>::ptr_t::operator=(const typename Singleton<T,_may_create>::ptr_t& rhs){
+  if(&rhs!=this){
+    delete content;
+    content = rhs.content;
+    rhs.content = 0;
+  }
+  return *this;
+}
+
+
+#endif /* SINGLETON_IMPL_HPP_ */
Index: src/Patterns/unittests/CacheableUnitTest.cpp
===================================================================
--- src/Patterns/unittests/CacheableUnitTest.cpp	(revision a80f4195d731fd366a976130725a3e131376108f)
+++ src/Patterns/unittests/CacheableUnitTest.cpp	(revision a80f4195d731fd366a976130725a3e131376108f)
@@ -0,0 +1,103 @@
+/*
+ * Project: MoleCuilder
+ * Description: creates and alters molecular systems
+ * Copyright (C)  2010 University of Bonn. All rights reserved.
+ * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
+ */
+
+/*
+ * CacheableUnitTest.cpp
+ *
+ *  Created on: Feb 2, 2010
+ *      Author: crueger
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "CacheableUnitTest.hpp"
+
+#include <cppunit/CompilerOutputter.h>
+#include <cppunit/extensions/TestFactoryRegistry.h>
+#include <cppunit/ui/text/TestRunner.h>
+
+#include <boost/bind.hpp>
+
+#include "Patterns/Cacheable.hpp"
+
+#ifdef HAVE_TESTRUNNER
+#include "UnitTestMain.hpp"
+#endif /*HAVE_TESTRUNNER*/
+
+/********************************************** Test classes **************************************/
+
+// Registers the fixture into the 'registry'
+CPPUNIT_TEST_SUITE_REGISTRATION( CacheableTest );
+
+class threeNumbers : public Observable {
+public:
+  int x;
+  int y;
+  int z;
+  Cacheable<int> sum;
+  bool hasRecalced;
+
+  void setX(int _x){
+    OBSERVE;
+    x = _x;
+  }
+
+  void setY
+  (int _y){
+    OBSERVE;
+    y = _y;
+  }
+
+  void setZ(int _z){
+    OBSERVE;
+    z = _z;
+  }
+
+  int calcSum(){
+    hasRecalced = true;
+    return x+y+z;
+  }
+
+  threeNumbers(int _x,int _y, int _z) :
+    Observable("threeNumbers"),
+    x(_x),y(_y),z(_z),
+    sum(this,boost::bind(&threeNumbers::calcSum,this),"sum"),
+    hasRecalced(false)
+  {}
+};
+
+
+
+
+void CacheableTest::setUp(){
+  numbers = new threeNumbers(1,2,3);
+}
+
+void CacheableTest::tearDown(){
+  delete numbers;
+}
+
+void CacheableTest::doesRecalcTest()
+{
+  CPPUNIT_ASSERT_EQUAL( 6, *(numbers->sum));
+  CPPUNIT_ASSERT_EQUAL( true, numbers->hasRecalced);
+  numbers->hasRecalced=false;
+  numbers->setX(4);
+  CPPUNIT_ASSERT_EQUAL( false, numbers->hasRecalced);
+  CPPUNIT_ASSERT_EQUAL( 9, *(numbers->sum));
+  CPPUNIT_ASSERT_EQUAL( true, numbers->hasRecalced);
+  numbers->hasRecalced=false;
+  CPPUNIT_ASSERT_EQUAL( 9, *(numbers->sum));
+#ifndef NO_CACHING
+  CPPUNIT_ASSERT_EQUAL( false, numbers->hasRecalced);
+#else
+  CPPUNIT_ASSERT_EQUAL( true, numbers->hasRecalced);
+#endif
+}
Index: src/Patterns/unittests/CacheableUnitTest.hpp
===================================================================
--- src/Patterns/unittests/CacheableUnitTest.hpp	(revision a80f4195d731fd366a976130725a3e131376108f)
+++ src/Patterns/unittests/CacheableUnitTest.hpp	(revision a80f4195d731fd366a976130725a3e131376108f)
@@ -0,0 +1,31 @@
+/*
+ * CacheableUnitTest.hpp
+ *
+ *  Created on: Feb 2, 2010
+ *      Author: crueger
+ */
+
+#ifndef CACHEABLEUNITTEST_HPP_
+#define CACHEABLEUNITTEST_HPP_
+
+#include <cppunit/extensions/HelperMacros.h>
+
+
+// stub classes
+class threeNumbers;
+
+class CacheableTest :  public CppUnit::TestFixture
+{
+  CPPUNIT_TEST_SUITE( CacheableTest );
+  CPPUNIT_TEST ( doesRecalcTest );
+  CPPUNIT_TEST_SUITE_END();
+
+public:
+  void setUp();
+  void tearDown();
+
+  void doesRecalcTest();
+  threeNumbers *numbers;
+};
+
+#endif /* CACHEABLEUNITTEST_HPP_ */
Index: src/Patterns/unittests/Makefile.am
===================================================================
--- src/Patterns/unittests/Makefile.am	(revision a80f4195d731fd366a976130725a3e131376108f)
+++ src/Patterns/unittests/Makefile.am	(revision a80f4195d731fd366a976130725a3e131376108f)
@@ -0,0 +1,52 @@
+# PLEASE adhere to the alphabetical ordering in this Makefile!
+# Also indentation by a single tab
+
+INCLUDES = -I$(top_srcdir)/src
+
+AM_LDFLAGS = $(CPPUNIT_LIBS) -ldl
+AM_CXXFLAGS = $(CPPUNIT_CFLAGS)
+AM_CPPFLAGS = ${BOOST_CPPFLAGS}
+
+TESTS = \
+  CacheableUnitTest \
+  ObserverUnitTest \
+  RegistryUnitTest \
+  SingletonUnitTest
+
+
+check_PROGRAMS = $(TESTS) 
+noinst_PROGRAMS = $(TESTS)
+
+BOOST_LIB = $(BOOST_LDFLAGS) $(BOOST_MPL_LIB) $(BOOST_PROGRAM_OPTIONS_LIB) $(BOOST_FILESYSTEM_LIB) $(BOOST_SYSTEM_LIB) $(BOOST_THREAD_LIB)
+TESTLIBS = \
+	../../libCodePatterns-@CODEPATTERNS_API_VERSION@.la \
+	$(BOOST_LIB)
+
+CacheableUnitTest_SOURCES = $(top_srcdir)/src/unittests/UnitTestMain.cpp \
+	CacheableUnitTest.cpp \
+	CacheableUnitTest.hpp \
+	../Cachable.hpp \
+	../Observer.cpp \
+	../Observer.hpp \
+	../ObserverIterator.hpp
+CacheableUnitTest_LDADD = $(TESTLIBS)
+
+ObserverUnitTest_SOURCES = $(top_srcdir)/src/unittests/UnitTestMain.cpp \
+	ObserverUnitTest.cpp \
+	ObserverUnitTest.hpp \
+	../Observer.cpp \
+	../Observer.hpp \
+	../ObserverIterator.hpp
+ObserverUnitTest_LDADD = $(TESTLIBS)
+
+RegistryUnitTest_SOURCES = $(top_srcdir)/src/unittests/UnitTestMain.cpp \
+	RegistryUnitTest.cpp \
+	RegistryUnitTest.hpp
+#RegistryUnitTest_LDADD = $(TESTLIBS)
+
+SingletonUnitTest_SOURCES = $(top_srcdir)/src/unittests/UnitTestMain.cpp \
+	SingletonUnitTest.cpp \
+	SingletonUnitTest.hpp
+SingletonUnitTest_LDADD = $(TESTLIBS)
+
+#AUTOMAKE_OPTIONS = parallel-tests
Index: src/Patterns/unittests/ObserverUnitTest.cpp
===================================================================
--- src/Patterns/unittests/ObserverUnitTest.cpp	(revision a80f4195d731fd366a976130725a3e131376108f)
+++ src/Patterns/unittests/ObserverUnitTest.cpp	(revision a80f4195d731fd366a976130725a3e131376108f)
@@ -0,0 +1,492 @@
+/*
+ * Project: MoleCuilder
+ * Description: creates and alters molecular systems
+ * Copyright (C)  2010 University of Bonn. All rights reserved.
+ * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
+ */
+
+/*
+ * ObserverTest.cpp
+ *
+ *  Created on: Jan 19, 2010
+ *      Author: crueger
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <cppunit/CompilerOutputter.h>
+#include <cppunit/extensions/TestFactoryRegistry.h>
+#include <cppunit/ui/text/TestRunner.h>
+#include <set>
+
+#include "Patterns/Observer.hpp"
+#include "Patterns/ObservedIterator.hpp"
+#include "Assert.hpp"
+
+#include <iostream>
+
+#include "ObserverUnitTest.hpp"
+
+#ifdef HAVE_TESTRUNNER
+#include "UnitTestMain.hpp"
+#endif /*HAVE_TESTRUNNER*/
+
+// Registers the fixture into the 'registry'
+CPPUNIT_TEST_SUITE_REGISTRATION( ObserverTest );
+
+/******************* Test stubs ************************/
+
+class UpdateCountObserver : public Observer {
+public:
+  UpdateCountObserver() :
+    Observer("UpdateCountObserver"),
+    updates(0)
+  {};
+  void update(Observable *publisher){
+    updates++;
+  }
+  void subjectKilled(Observable *publisher) {
+  }
+  int updates;
+};
+
+class SimpleObservable : public Observable {
+public:
+  SimpleObservable() :
+    Observable("SimpleObservable")
+  {}
+
+  void changeMethod() {
+    OBSERVE;
+    int i = 0;
+    i++;
+  }
+};
+
+class CallObservable : public Observable {
+public:
+  CallObservable() :
+    Observable("CallObservable")
+  {}
+
+  void changeMethod1() {
+    OBSERVE;
+    int i = 0;
+    i++;
+  }
+
+  void changeMethod2() {
+    OBSERVE;
+    int i = 0;
+    i++;
+    changeMethod1();
+  }
+};
+
+class BlockObservable : public Observable {
+public:
+  BlockObservable() :
+    Observable("BlockObservable")
+  {}
+
+  void changeMethod1(){
+    OBSERVE;
+    // test if we report correctly as blocked
+    CPPUNIT_ASSERT(isBlocked());
+  }
+
+  void changeMethod2(){
+    OBSERVE;
+    internalMethod1();
+    internalMethod2();
+  }
+
+  void internalMethod1(){
+    // we did not block, but our caller did...
+    // see if this is found
+    CPPUNIT_ASSERT(isBlocked());
+  }
+
+  void internalMethod2(){
+    OBSERVE;
+    // Both this method and the caller do block
+    // Does the reporting still work as expected?
+    CPPUNIT_ASSERT(isBlocked());
+  }
+
+  void noChangeMethod(){
+    // No Block introduced here
+    // reported correctely?
+    CPPUNIT_ASSERT(!isBlocked());
+  }
+};
+
+class SuperObservable : public Observable {
+public:
+  SuperObservable():
+    Observable("SuperObservable")
+  {
+    subObservable = new SimpleObservable();
+    subObservable->signOn(this);
+  }
+  ~SuperObservable(){
+    delete subObservable;
+  }
+  void changeMethod() {
+    OBSERVE;
+    int i = 0;
+    i++;
+    subObservable->changeMethod();
+  }
+  SimpleObservable *subObservable;
+};
+
+class NotificationObservable : public Observable {
+public:
+  NotificationObservable() :
+    Observable("NotificationObservable"),
+    notification1(new Notification(this)),
+    notification2(new Notification(this))
+  {}
+
+  ~NotificationObservable(){
+    delete notification1;
+    delete notification2;
+  }
+
+  void operation1(){
+    OBSERVE;
+    NOTIFY(notification1);
+  }
+
+  void operation2(){
+    OBSERVE;
+    NOTIFY(notification2);
+  }
+
+  Notification_ptr notification1;
+  Notification_ptr notification2;
+};
+
+class NotificationObserver : public Observer {
+public:
+  NotificationObserver(Notification_ptr notification) :
+    Observer("NotificationObserver"),
+    requestedNotification(notification),
+    wasNotified(false)
+  {}
+
+  void update(Observable*){}
+  void subjectKilled(Observable*){}
+  void recieveNotification(Observable *publisher, Notification_ptr notification){
+    ASSERT(requestedNotification==notification,"Notification received that was not requested");
+    wasNotified = true;
+  }
+
+  Notification_ptr requestedNotification;
+
+  bool wasNotified;
+};
+
+class ObservableSet : public Observable {
+public:
+  typedef std::set<SimpleObservable*> set;
+  typedef ObservedIterator<set> iterator;
+  typedef set::const_iterator const_iterator;
+
+  ObservableSet(int _num) :
+    Observable("ObservableCollection"),
+    num(_num)
+  {
+    for(int i=0; i<num; ++i){
+      SimpleObservable *content = new SimpleObservable();
+      content->signOn(this);
+      theSet.insert(content);
+    }
+  }
+
+  ~ObservableSet(){
+    set::iterator iter;
+    for(iter=theSet.begin(); iter!=theSet.end(); ++iter ){
+      delete (*iter);
+    }
+  }
+
+  iterator begin(){
+    return iterator(theSet.begin(),this);
+  }
+
+  iterator end(){
+    return iterator(theSet.end(),this);
+  }
+
+  const int num;
+
+private:
+  set theSet;
+};
+
+class ObservableMap : public Observable {
+public:
+  typedef std::map<int,SimpleObservable*> set;
+  typedef ObservedIterator<set> iterator;
+  typedef set::const_iterator const_iterator;
+
+  ObservableMap(int _num) :
+    Observable("ObservableCollection"),
+    num(_num)
+  {
+    for(int i=0; i<num; ++i){
+      SimpleObservable *content = new SimpleObservable();
+      content->signOn(this);
+      theSet.insert(std::make_pair(i,content));
+    }
+  }
+
+  ~ObservableMap(){
+    set::iterator iter;
+    for(iter=theSet.begin(); iter!=theSet.end(); ++iter ){
+      delete iter->second;
+    }
+  }
+
+  iterator begin(){
+    return iterator(theSet.begin(),this);
+  }
+
+  iterator end(){
+    return iterator(theSet.end(),this);
+  }
+
+  const int num;
+
+private:
+  set theSet;
+};
+
+
+/******************* actuall tests ***************/
+
+void ObserverTest::setUp() {
+  ASSERT_DO(Assert::Throw);
+  simpleObservable1 = new SimpleObservable();
+  simpleObservable2 = new SimpleObservable();
+  callObservable = new CallObservable();
+  superObservable = new SuperObservable();
+  blockObservable = new BlockObservable();
+  notificationObservable = new NotificationObservable();
+  obsset = new ObservableSet(5);
+  obsmap = new ObservableMap(5);
+
+  observer1 = new UpdateCountObserver();
+  observer2 = new UpdateCountObserver();
+  observer3 = new UpdateCountObserver();
+  observer4 = new UpdateCountObserver();
+
+  notificationObserver1 = new NotificationObserver(notificationObservable->notification1);
+  notificationObserver2 = new NotificationObserver(notificationObservable->notification2);
+}
+
+void ObserverTest::tearDown() {
+  delete simpleObservable1;
+  delete simpleObservable2;
+  delete callObservable;
+  delete superObservable;
+  delete blockObservable;
+  delete notificationObservable;
+  delete obsset;
+  delete obsmap;
+
+  delete observer1;
+  delete observer2;
+  delete observer3;
+  delete observer4;
+  delete notificationObserver1;
+  delete notificationObserver2;
+}
+
+void ObserverTest::doesUpdateTest()
+{
+  simpleObservable1->signOn(observer1);
+  simpleObservable1->signOn(observer2);
+  simpleObservable1->signOn(observer3);
+
+  simpleObservable2->signOn(observer2);
+  simpleObservable2->signOn(observer4);
+
+  CPPUNIT_ASSERT_EQUAL( 0, observer1->updates );
+  CPPUNIT_ASSERT_EQUAL( 0, observer2->updates );
+  CPPUNIT_ASSERT_EQUAL( 0, observer3->updates );
+  CPPUNIT_ASSERT_EQUAL( 0, observer4->updates );
+
+
+  simpleObservable1->changeMethod();
+  CPPUNIT_ASSERT_EQUAL( 1, observer1->updates );
+  CPPUNIT_ASSERT_EQUAL( 1, observer2->updates );
+  CPPUNIT_ASSERT_EQUAL( 1, observer3->updates );
+  CPPUNIT_ASSERT_EQUAL( 0, observer4->updates );
+
+  simpleObservable1->signOff(observer3);
+
+  simpleObservable1->changeMethod();
+  CPPUNIT_ASSERT_EQUAL( 2, observer1->updates );
+  CPPUNIT_ASSERT_EQUAL( 2, observer2->updates );
+  CPPUNIT_ASSERT_EQUAL( 1, observer3->updates );
+  CPPUNIT_ASSERT_EQUAL( 0, observer4->updates );
+
+  simpleObservable2->changeMethod();
+  CPPUNIT_ASSERT_EQUAL( 2, observer1->updates );
+  CPPUNIT_ASSERT_EQUAL( 3, observer2->updates );
+  CPPUNIT_ASSERT_EQUAL( 1, observer3->updates );
+  CPPUNIT_ASSERT_EQUAL( 1, observer4->updates );
+}
+
+
+void ObserverTest::doesBlockUpdateTest() {
+  callObservable->signOn(observer1);
+  CPPUNIT_ASSERT_EQUAL( 0, observer1->updates );
+
+  callObservable->changeMethod1();
+  CPPUNIT_ASSERT_EQUAL( 1, observer1->updates );
+
+  callObservable->changeMethod2();
+  CPPUNIT_ASSERT_EQUAL( 2, observer1->updates );
+}
+
+void ObserverTest::doesSubObservableTest() {
+  superObservable->signOn(observer1);
+  superObservable->subObservable->signOn(observer2);
+
+  superObservable->subObservable->changeMethod();
+  CPPUNIT_ASSERT_EQUAL( 1, observer1->updates );
+  CPPUNIT_ASSERT_EQUAL( 1, observer2->updates );
+
+  superObservable->changeMethod();
+  CPPUNIT_ASSERT_EQUAL( 2, observer1->updates );
+  CPPUNIT_ASSERT_EQUAL( 2, observer2->updates );
+}
+
+void ObserverTest::outsideLockTest(){
+  callObservable->signOn(observer1);
+  CPPUNIT_ASSERT_EQUAL( 0, observer1->updates );
+
+  {
+    LOCK_OBSERVABLE(*callObservable);
+    CPPUNIT_ASSERT_EQUAL( 0, observer1->updates );
+  }
+  // lock is gone now, observer should have notified
+  CPPUNIT_ASSERT_EQUAL( 1, observer1->updates );
+}
+
+void ObserverTest::doesNotifyTest(){
+  notificationObservable->signOn(notificationObserver1,
+                                 notificationObservable->notification1);
+  notificationObservable->signOn(notificationObserver2,
+                                 notificationObservable->notification2);
+
+  notificationObservable->operation1();
+  CPPUNIT_ASSERT(notificationObserver1->wasNotified);
+  CPPUNIT_ASSERT(!notificationObserver2->wasNotified);
+
+  notificationObserver1->wasNotified=false;
+
+  notificationObservable->operation2();
+  CPPUNIT_ASSERT(!notificationObserver1->wasNotified);
+  CPPUNIT_ASSERT(notificationObserver2->wasNotified);
+
+}
+
+void ObserverTest::doesReportTest(){
+  // Actual checks are in the Stub-methods for this
+  blockObservable->changeMethod1();
+  blockObservable->changeMethod2();
+  blockObservable->noChangeMethod();
+}
+
+void ObserverTest::iteratorTest(){
+  int i = 0;
+  // test the general iterator methods
+  for(ObservableSet::iterator iter=obsset->begin(); iter!=obsset->end();++iter){
+    CPPUNIT_ASSERT(i< obsset->num);
+    i++;
+  }
+
+  i=0;
+  for(ObservableSet::const_iterator iter=obsset->begin(); iter!=obsset->end();++iter){
+    CPPUNIT_ASSERT(i<obsset->num);
+    i++;
+  }
+
+  obsset->signOn(observer1);
+  {
+    // we construct this out of the loop, so the iterator dies at the end of
+    // the scope and not the end of the loop (allows more testing)
+    ObservableSet::iterator iter;
+    for(iter=obsset->begin(); iter!=obsset->end(); ++iter){
+      (*iter)->changeMethod();
+    }
+    // At this point no change should have been propagated
+    CPPUNIT_ASSERT_EQUAL( 0, observer1->updates);
+  }
+  // After the Iterator has died the propagation should take place
+  CPPUNIT_ASSERT_EQUAL( 1, observer1->updates);
+
+  // when using a const_iterator no changes should be propagated
+  for(ObservableSet::const_iterator iter = obsset->begin(); iter!=obsset->end();++iter);
+  CPPUNIT_ASSERT_EQUAL( 1, observer1->updates);
+
+  // we need to test the operator-> as well
+  obsmap->signOn(observer2);
+  {
+    // we construct this out of the loop, so the iterator dies at the end of
+    // the scope and not the end of the loop (allows more testing)
+    ObservableMap::iterator iter;
+    for(iter=obsmap->begin(); iter!=obsmap->end(); ++iter){
+      iter->second->changeMethod();
+    }
+    // At this point no change should have been propagated
+    CPPUNIT_ASSERT_EQUAL( 0, observer2->updates);
+  }
+  // After the Iterator has died the propagation should take place
+  CPPUNIT_ASSERT_EQUAL( 1, observer2->updates);
+
+
+  obsset->signOff(observer1);
+  obsmap->signOff(observer2);
+}
+
+void ObserverTest::CircleDetectionTest() {
+  std::cout << std::endl << "Warning: the next test involved methods that can produce infinite loops." << std::endl;
+  std::cout << "Errors in this methods can not be checked using the CPPUNIT_ASSERT Macros." << std::endl;
+  std::cout << "Instead tests are run on these methods to see if termination is assured" << std::endl << std::endl;
+  std::cout << "If this test does not complete in a few seconds, kill the test-suite and fix the Error in the circle detection mechanism" << std::endl;
+
+  std::cout << std::endl << std::endl << "The following errors displayed by the observer framework can be ignored" << std::endl;
+
+  // make this Observable its own subject. NEVER DO THIS IN ACTUAL CODE
+  simpleObservable1->signOn(simpleObservable1);
+#ifndef NDEBUG
+  CPPUNIT_ASSERT_THROW(simpleObservable1->changeMethod(),Assert::AssertionFailure);
+#else
+  simpleObservable1->changeMethod();
+#endif
+
+  // more complex test
+  simpleObservable1->signOff(simpleObservable1);
+  simpleObservable1->signOn(simpleObservable2);
+  simpleObservable2->signOn(simpleObservable1);
+#ifndef NDEBUG
+  CPPUNIT_ASSERT_THROW(simpleObservable1->changeMethod(),Assert::AssertionFailure);
+#else
+  simpleObservable1->changeMethod();
+#endif
+
+
+  simpleObservable1->signOff(simpleObservable2);
+  simpleObservable2->signOff(simpleObservable1);
+  // when we reach this line, although we broke the DAG assumption the circle check works fine
+  CPPUNIT_ASSERT(true);
+}
Index: src/Patterns/unittests/ObserverUnitTest.hpp
===================================================================
--- src/Patterns/unittests/ObserverUnitTest.hpp	(revision a80f4195d731fd366a976130725a3e131376108f)
+++ src/Patterns/unittests/ObserverUnitTest.hpp	(revision a80f4195d731fd366a976130725a3e131376108f)
@@ -0,0 +1,70 @@
+/*
+ * ObserverTest.hpp
+ *
+ *  Created on: Jan 19, 2010
+ *      Author: crueger
+ */
+
+#ifndef OBSERVERTEST_HPP_
+#define OBSERVERTEST_HPP_
+
+#include <cppunit/extensions/HelperMacros.h>
+
+// forward declaration for test stubs
+class UpdateCountObserver;
+class NotificationObserver;
+class SimpleObservable;
+class CallObservable;
+class SuperObservable;
+class ObservableSet;
+class ObservableMap;
+class BlockObservable;
+class NotificationObservable;
+
+class ObserverTest :  public CppUnit::TestFixture
+{
+  CPPUNIT_TEST_SUITE( ObserverTest ) ;
+  CPPUNIT_TEST ( doesUpdateTest );
+  CPPUNIT_TEST ( doesBlockUpdateTest );
+  CPPUNIT_TEST ( doesSubObservableTest );
+  CPPUNIT_TEST ( outsideLockTest );
+  CPPUNIT_TEST ( doesNotifyTest );
+  CPPUNIT_TEST ( doesReportTest );
+  CPPUNIT_TEST ( iteratorTest );
+  CPPUNIT_TEST ( CircleDetectionTest );
+  CPPUNIT_TEST_SUITE_END();
+
+public:
+  void setUp();
+  void tearDown();
+
+  void doesUpdateTest();
+  void doesBlockUpdateTest();
+  void doesSubObservableTest();
+  void outsideLockTest();
+  void doesNotifyTest();
+  void doesReportTest();
+  void iteratorTest();
+  void CircleDetectionTest();
+
+private:
+  UpdateCountObserver *observer1;
+  UpdateCountObserver *observer2;
+  UpdateCountObserver *observer3;
+  UpdateCountObserver *observer4;
+
+  NotificationObserver *notificationObserver1;
+  NotificationObserver *notificationObserver2;
+
+  SimpleObservable *simpleObservable1;
+  SimpleObservable *simpleObservable2;
+  CallObservable *callObservable;
+  BlockObservable *blockObservable;
+  SuperObservable *superObservable;
+  NotificationObservable *notificationObservable;
+  ObservableSet *obsset;
+  ObservableMap *obsmap;
+
+};
+
+#endif /* OBSERVERTEST_HPP_ */
Index: src/Patterns/unittests/RegistryUnitTest.cpp
===================================================================
--- src/Patterns/unittests/RegistryUnitTest.cpp	(revision a80f4195d731fd366a976130725a3e131376108f)
+++ src/Patterns/unittests/RegistryUnitTest.cpp	(revision a80f4195d731fd366a976130725a3e131376108f)
@@ -0,0 +1,48 @@
+/*
+ * Project: MoleCuilder
+ * Description: creates and alters molecular systems
+ * Copyright (C)  2010 University of Bonn. All rights reserved.
+ * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
+ */
+
+/*
+ * RegistryUnitTest.cpp
+ *
+ *  Created on: Oct 27, 2010
+ *      Author: heber
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <cppunit/CompilerOutputter.h>
+#include <cppunit/extensions/TestFactoryRegistry.h>
+#include <cppunit/ui/text/TestRunner.h>
+
+#include <typeinfo>
+
+#include "RegistryUnitTest.hpp"
+
+#ifdef HAVE_TESTRUNNER
+#include "UnitTestMain.hpp"
+#endif /*HAVE_TESTRUNNER*/
+
+/********************************************** Test classes **************************************/
+
+// Registers the fixture into the 'registry'
+CPPUNIT_TEST_SUITE_REGISTRATION( RegistryTest );
+
+
+void RegistryTest::setUp()
+{};
+
+
+void RegistryTest::tearDown()
+{};
+
+void RegistryTest::InOutCheck()
+{
+  CPPUNIT_ASSERT(true);
+}
Index: src/Patterns/unittests/RegistryUnitTest.hpp
===================================================================
--- src/Patterns/unittests/RegistryUnitTest.hpp	(revision a80f4195d731fd366a976130725a3e131376108f)
+++ src/Patterns/unittests/RegistryUnitTest.hpp	(revision a80f4195d731fd366a976130725a3e131376108f)
@@ -0,0 +1,30 @@
+/*
+ * RegistryUnitTest.hpp
+ *
+ *  Created on: Oct 27, 2010
+ *      Author: heber
+ */
+
+#ifndef REGISTRYUNITTEST_HPP_
+#define REGISTRYUNITTEST_HPP_
+
+#include <cppunit/extensions/HelperMacros.h>
+
+
+/********************************************** Test classes **************************************/
+
+class RegistryTest : public CppUnit::TestFixture
+{
+    CPPUNIT_TEST_SUITE( RegistryTest) ;
+    CPPUNIT_TEST ( InOutCheck );
+    CPPUNIT_TEST_SUITE_END();
+
+public:
+      void setUp();
+      void tearDown();
+      void InOutCheck();
+
+private:
+};
+
+#endif /* REGISTRYUNITTEST_HPP_ */
Index: src/Patterns/unittests/SingletonUnitTest.cpp
===================================================================
--- src/Patterns/unittests/SingletonUnitTest.cpp	(revision a80f4195d731fd366a976130725a3e131376108f)
+++ src/Patterns/unittests/SingletonUnitTest.cpp	(revision a80f4195d731fd366a976130725a3e131376108f)
@@ -0,0 +1,155 @@
+/*
+ * Project: MoleCuilder
+ * Description: creates and alters molecular systems
+ * Copyright (C)  2010 University of Bonn. All rights reserved.
+ * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
+ */
+
+/*
+ * SingletonUnitTest.cpp
+ *
+ *  Created on: Mar 11, 2010
+ *      Author: crueger
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "SingletonUnitTest.hpp"
+
+#include <cppunit/CompilerOutputter.h>
+#include <cppunit/extensions/TestFactoryRegistry.h>
+#include <cppunit/ui/text/TestRunner.h>
+#include <iostream>
+
+#include "Patterns/Singleton.hpp"
+#include "Patterns/Singleton_impl.hpp"
+
+#ifdef HAVE_TESTRUNNER
+#include "UnitTestMain.hpp"
+#endif /*HAVE_TESTRUNNER*/
+
+CPPUNIT_TEST_SUITE_REGISTRATION( SingletonTest );
+
+// some necessary stubs
+class SingletonStub1 : public Singleton <SingletonStub1>{
+  friend class Singleton<SingletonStub1>;
+private:
+  SingletonStub1(){
+    count1++;
+  }
+  // explicit copy constructor to catch if this is ever called
+  SingletonStub1(const SingletonStub1&){
+    CPPUNIT_FAIL    ( "Copy constructor of Singleton called" );
+  }
+  virtual ~SingletonStub1(){
+    count2++;
+  }
+public:
+  static int count1;
+  static int count2;
+};
+
+int SingletonStub1::count1 = 0;
+int SingletonStub1::count2 = 0;
+
+CONSTRUCT_SINGLETON(SingletonStub1);
+
+class SingletonStub2 : public Singleton<SingletonStub2>{
+  friend class Singleton<SingletonStub2>;
+private:
+  SingletonStub2(){
+    count1++;
+  }
+  // explicit copy constructor to catch if this is ever called
+  SingletonStub2(const SingletonStub2&){
+    CPPUNIT_FAIL    ( "Copy constructor of Singleton called" );
+  }
+  virtual ~SingletonStub2(){
+    count2++;
+  }
+public:
+  static int count1;
+  static int count2;
+};
+
+int SingletonStub2::count1 = 0;
+int SingletonStub2::count2 = 0;
+
+CONSTRUCT_SINGLETON(SingletonStub2);
+
+void SingletonTest::setUp(){}
+void SingletonTest::tearDown(){}
+
+void SingletonTest::ConstructionTest(){
+  void *ptr_1_1 = reinterpret_cast<void*>(SingletonStub1::getPointer());
+  void *ptr_1_2 = reinterpret_cast<void*>(SingletonStub1::getPointer());
+  void *ptr_1_3 = reinterpret_cast<void*>(&(SingletonStub1::getInstance()));
+
+  // test if we always get the same instance of our singleton
+  CPPUNIT_ASSERT_EQUAL(ptr_1_1,ptr_1_2);
+  CPPUNIT_ASSERT_EQUAL(ptr_1_1,ptr_1_3);
+
+  void *ptr_2_1 = reinterpret_cast<void*>(SingletonStub2::getPointer());
+  void *ptr_2_2 = reinterpret_cast<void*>(SingletonStub2::getPointer());
+  void *ptr_2_3 = reinterpret_cast<void*>(&(SingletonStub2::getInstance()));
+
+  // same as above but for a different singleton
+  CPPUNIT_ASSERT_EQUAL(ptr_2_1,ptr_2_2);
+  CPPUNIT_ASSERT_EQUAL(ptr_2_1,ptr_2_3);
+
+  // see if the two singletons actually differ
+  CPPUNIT_ASSERT(ptr_1_1!=ptr_2_1);
+
+  // see if each constructor was called exactly once
+  CPPUNIT_ASSERT_EQUAL(1,SingletonStub1::count1);
+  CPPUNIT_ASSERT_EQUAL(1,SingletonStub2::count1);
+  // no calls to the destructor should have occured so far
+  CPPUNIT_ASSERT_EQUAL(0,SingletonStub1::count2);
+  CPPUNIT_ASSERT_EQUAL(0,SingletonStub2::count2);
+
+  SingletonStub1::purgeInstance();
+
+  void *ptr_3_1 = reinterpret_cast<void*>(SingletonStub1::getPointer());
+  void *ptr_3_2 = reinterpret_cast<void*>(SingletonStub1::getPointer());
+
+  // now the constructor should have been called twice
+  CPPUNIT_ASSERT_EQUAL(2,SingletonStub1::count1);
+  // the destructor should have been called once
+  CPPUNIT_ASSERT_EQUAL(1,SingletonStub1::count2);
+  // see if the singleton Assumption holds
+  CPPUNIT_ASSERT_EQUAL(ptr_3_1,ptr_3_2);
+  // Some esoteric thing might cause our pointer to lay at the position of Singleton2 now
+  // See that those two objects still differ
+  CPPUNIT_ASSERT(ptr_3_1!=ptr_2_1);
+  // don't test for pointer difference between first and second singleton here,
+  // because they might be constructed in the same place
+
+
+  SingletonStub2::resetInstance();
+  // now the constructor should have been called twice
+  CPPUNIT_ASSERT_EQUAL(2,SingletonStub2::count1);
+  // the destructor should have been called once
+  CPPUNIT_ASSERT_EQUAL(1,SingletonStub2::count2);
+
+  void *ptr_4_1 = reinterpret_cast<void*>(SingletonStub2::getPointer());
+  void *ptr_4_2 = reinterpret_cast<void*>(SingletonStub2::getPointer());
+
+  // Still only two calls to the constructor, one call to destructor
+  CPPUNIT_ASSERT_EQUAL(2,SingletonStub2::count1);
+  CPPUNIT_ASSERT_EQUAL(1,SingletonStub2::count2);
+
+  // test if Singleton assumption can be broken by reset
+  CPPUNIT_ASSERT_EQUAL(ptr_4_1,ptr_4_2);
+
+  // and again test if we actually have a object seperate from anything else
+  CPPUNIT_ASSERT(ptr_4_1!=ptr_3_1);
+
+
+  // we don't purge our singletons here. Purging should be done automatically by the Singleton
+  // mechanism. Check with Valgrind to see if memory-leak occurs
+  std::cout << "Not purging Singleton!\n Check with Valgrind to see if automatic purgins is working!" << std::endl;
+
+}
Index: src/Patterns/unittests/SingletonUnitTest.hpp
===================================================================
--- src/Patterns/unittests/SingletonUnitTest.hpp	(revision a80f4195d731fd366a976130725a3e131376108f)
+++ src/Patterns/unittests/SingletonUnitTest.hpp	(revision a80f4195d731fd366a976130725a3e131376108f)
@@ -0,0 +1,26 @@
+/*
+ * SingletonUnitTest.hpp
+ *
+ *  Created on: Mar 11, 2010
+ *      Author: crueger
+ */
+
+#ifndef SINGLETONUNITTEST_HPP_
+#define SINGLETONUNITTEST_HPP_
+
+#include <cppunit/extensions/HelperMacros.h>
+
+class SingletonTest : public CppUnit::TestFixture
+{
+  CPPUNIT_TEST_SUITE( SingletonTest );
+  CPPUNIT_TEST ( ConstructionTest );
+  CPPUNIT_TEST_SUITE_END();
+
+public:
+  void setUp();
+  void tearDown();
+
+  void ConstructionTest();
+};
+
+#endif /* SINGLETONUNITTEST_HPP_ */
Index: src/Range.hpp
===================================================================
--- src/Range.hpp	(revision a80f4195d731fd366a976130725a3e131376108f)
+++ src/Range.hpp	(revision a80f4195d731fd366a976130725a3e131376108f)
@@ -0,0 +1,65 @@
+/*
+ * Range.hpp
+ *
+ *  Created on: Jul 22, 2010
+ *      Author: crueger
+ */
+
+#ifndef RANGE_HPP_
+#define RANGE_HPP_
+template <class T>
+struct range {
+  range(const T&,const T&);
+  bool isInRange(const T&) const;
+  bool isBefore(const T&) const;
+  bool isBeyond(const T&) const;
+
+  T first;
+  T last;
+};
+
+template <class T>
+inline range<T>::range(const T &_first,const T &_last) :
+first(_first),last(_last)
+{}
+
+template <class T>
+inline bool range<T>::isInRange(const T &value) const{
+  return first <= value && value < last;
+}
+
+template <class T>
+inline bool range<T>::isBefore(const T &value) const{
+  return value < first;
+}
+
+template <class T>
+inline bool range<T>::isBeyond(const T &value) const{
+ return last <= value;
+}
+
+template <class T>
+inline range<T> makeRange(const T&first, const T&last){
+  return range<T>(first,last);
+}
+
+template <class T>
+inline bool operator<(const range <T> &x, const range<T> &y){
+  return (x.first!=y.first)?x.first<y.first:x.last<y.last;
+}
+
+template <class T>
+inline bool operator==(const range<T> &x,const range<T> &y){
+  return x.first==y.first && x.last==y.last;
+}
+
+template <class T>
+inline bool operator!= (const range<T>& x, const range<T>& y) { return !(x==y); }
+template <class T>
+inline bool operator>  (const range<T>& x, const range<T>& y) { return y<x; }
+template <class T>
+inline bool operator<=(const range<T>& x, const range<T>& y) { return !(y<x); }
+template <class T>
+inline bool operator>= (const range<T>& x, const range<T>& y) { return !(x<y); }
+
+#endif /* RANGE_HPP_ */
Index: src/Verbose.cpp
===================================================================
--- src/Verbose.cpp	(revision a80f4195d731fd366a976130725a3e131376108f)
+++ src/Verbose.cpp	(revision a80f4195d731fd366a976130725a3e131376108f)
@@ -0,0 +1,102 @@
+/*
+ * Project: MoleCuilder
+ * Description: creates and alters molecular systems
+ * Copyright (C)  2010 University of Bonn. All rights reserved.
+ * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
+ */
+
+/** \file Verbose.cpp
+ *
+ * Function implementations for the class Verbose.
+ *
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "MemDebug.hpp"
+
+#include "Info.hpp"
+#include "Verbose.hpp"
+#include <iostream>
+
+using namespace std;
+
+/** Prints the tabs according to verbosity stored in the temporary constructed class.
+ * \param &ost stream to extend with tabs
+ * \return &ost stream with tabs
+ */
+ostream& Verbose::print (ostream &ost) const
+{
+  for (int i=Verbosity+Info::verbosity;i--;)
+    ost.put('\t');
+  //Log() << Verbose(0) << "Verbose(.) called." << endl;
+  return ost;
+};
+
+/** States whether current output message should be print or not.
+ * Compares Verbose::Verbosity plus Info::verbosity against \a verbosityLevel.
+ * \param verbosityLevel given global level of verbosity
+ * \return true - do output, false - don't
+ */
+bool Verbose::DoOutput(int verbosityLevel) const
+{
+  return (verbosityLevel >= Verbosity+Info::verbosity);
+};
+
+/** States whether current error output message should be print or not.
+ * Compares Verbose::Verbosity against \a verbosityLevel.
+ * \param verbosityLevel given global level of verbosity
+ * \return true - do output, false - don't
+ */
+bool Verbose::DoErrorOutput(int verbosityLevel) const
+{
+  return (verbosityLevel >= Verbosity);
+};
+
+/** Operator for the Verbose(arg) call.
+ * Constructs temporary a Verbose class object, wherein the verbosity is stored.
+ * Then << is called, which calls Verbose's print which adds the tabs and returns the stream.
+ * \param &ost stream to extend
+ * \param &m pointer to created Verbose object
+ * \return &ost
+ */ 
+ostream& operator<<(ostream& ost,const Verbose& m)
+{
+  return m.print(ost);
+};
+
+/** Prints the tabs according to verbosity stored in the temporary constructed class.
+ * Note that highest bit is set artificially to give number of bits to print
+ * \param &ost stream to extend with tabs
+ * \return &ost stream with tabs
+ */
+ostream& Binary::print (ostream &ost) const
+{
+  int bits = 1, counter = 1;
+  while ((bits = 1 << counter) < BinaryNumber)
+    counter++;
+  for (int i=0;i<counter-1;i++) {
+    if ((BinaryNumber & (1 << i)) == 0)
+      ost.put('0');
+     else
+      ost.put('1');
+  }
+  ost.put('b');
+  //Log() << Verbose(0) << "Binary(.) called." << endl;
+  return ost;
+};
+
+/** Operator for the Binary(arg) call.
+ * Constructs temporary a Verbose class object, wherein the Binary is stored.
+ * Then << is called, which calls Binary's print which adds the tabs and returns the stream.
+ * \param &ost stream to extend
+ * \param &m pointer to created Binary object
+ * \return &ost
+ */ 
+ostream& operator<<(ostream& ost,const Binary& m)
+{
+  return m.print(ost);
+};
Index: src/Verbose.hpp
===================================================================
--- src/Verbose.hpp	(revision a80f4195d731fd366a976130725a3e131376108f)
+++ src/Verbose.hpp	(revision a80f4195d731fd366a976130725a3e131376108f)
@@ -0,0 +1,62 @@
+/*
+ * verbose.hpp
+ *
+ *  Created on: Aug 3, 2009
+ *      Author: heber
+ */
+
+#ifndef VERBOSE_HPP_
+#define VERBOSE_HPP_
+
+using namespace std;
+
+/*********************************************** includes ***********************************/
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <iosfwd>
+
+/************************************* Class Verbose & Binary *******************************/
+
+/** Verbose is an IO manipulator, that writes tabs according to \a Verbosity level.
+ */
+class Verbose
+{
+  public:
+    Verbose(int value) : Verbosity(value) { }
+
+    // allow access to private variable Verbose::Verbosity
+    friend ostream& operator<<(class errorLogger& l, const Verbose& v);
+    friend ostream& operator<<(class errorLogger* l, const Verbose& v);
+    friend ostream& operator<<(class logger& l, const Verbose& v);
+    friend ostream& operator<<(class logger* l, const Verbose& v);
+
+    ostream& print (ostream &ost) const;
+    bool DoOutput(int verbosityLevel) const;
+    bool DoErrorOutput(int verbosityLevel) const;
+  private:
+    int Verbosity;
+};
+
+ostream& operator<<(ostream& ost,const Verbose& m);
+
+/** Binary is an IO manipulator, that writes 0 and 1 according to number \a Binary.
+ */
+class Binary
+{
+  public:
+    Binary(int value) : BinaryNumber(value) { }
+
+    ostream& print (ostream &ost) const;
+  private:
+    int BinaryNumber;
+};
+
+ostream& operator<<(ostream& ost,const Binary& m);
+
+
+
+#endif /* VERBOSE_HPP_ */
Index: src/errorlogger.cpp
===================================================================
--- src/errorlogger.cpp	(revision a80f4195d731fd366a976130725a3e131376108f)
+++ src/errorlogger.cpp	(revision a80f4195d731fd366a976130725a3e131376108f)
@@ -0,0 +1,125 @@
+/*
+ * Project: MoleCuilder
+ * Description: creates and alters molecular systems
+ * Copyright (C)  2010 University of Bonn. All rights reserved.
+ * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
+ */
+
+/*
+ * errorLogger.cpp
+ *
+ *  Created on: Oct 19, 2009
+ *      Author: metzler
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "MemDebug.hpp"
+
+#include <fstream>
+#include <iostream>
+#include "errorlogger.hpp"
+#include "Verbose.hpp"
+#include "Patterns/Singleton_impl.hpp"
+
+int errorLogger::verbosity = 2;
+ostream* errorLogger::nix = NULL;
+
+/**
+ * Constructor. Do not use this function. Use getInstance() instead.
+ *
+ * \return errorLogger instance
+ */
+errorLogger::errorLogger()
+{
+  nix = new ofstream("/dev/null");
+};
+
+/**
+ * Destructor. Better use purgeInstance().
+ */
+errorLogger::~errorLogger()
+{
+  delete nix;
+}
+
+CONSTRUCT_SINGLETON(errorLogger)
+
+/**
+ * Sets the verbosity.
+ *
+ * \param verbosityLevel verbosity
+ */
+void errorLogger::setVerbosity(int verbosityLevel) {
+  verbosity = verbosityLevel;
+}
+
+/**
+ * Gets the verbosity.
+ *
+ * \return verbosity level
+ */
+int errorLogger::getVerbosity()
+{
+  return verbosity;
+}
+
+/**
+ * Operator for the Binary(arg) call.
+ * Constructs temporary a Verbose class object, wherein the Binary is stored.
+ * Then << is called, which calls Binary's print which adds the tabs and logs
+ * the stream.
+ * \param &ost stream to extend
+ * \param &m pointer to created Binary object
+ * \return &ost
+ */
+ostream& operator<<(class errorLogger& l, const Verbose& v)
+{
+  int verbosityLevel = l.verbosity;
+  l.nix->clear();
+  if (v.DoErrorOutput(verbosityLevel)) {
+    switch(v.Verbosity) {
+      case 0:
+        cerr << "CRITICAL: ";
+        break;
+      case 1:
+        cerr << "ERROR: ";
+        break;
+      case 2:
+        cerr << "WARNING: ";
+        break;
+      default:
+        break;
+    }
+    v.print(cerr);
+    return cerr;
+  } else
+    return *l.nix;
+};
+ostream& operator<<(class errorLogger* l, const Verbose& v)
+{
+  int verbosityLevel = l->verbosity;
+  l->nix->clear();
+  if (v.DoErrorOutput(verbosityLevel)) {
+    switch(v.Verbosity) {
+      case 0:
+        cerr << "CRITICAL: ";
+        break;
+      case 1:
+        cerr << "ERROR: ";
+        break;
+      case 2:
+      default:
+        cerr << "WARNING: ";
+        break;
+    }
+    v.print(cerr);
+    return cerr;
+  } else
+    return *l->nix;
+};
+
+
Index: src/errorlogger.hpp
===================================================================
--- src/errorlogger.hpp	(revision a80f4195d731fd366a976130725a3e131376108f)
+++ src/errorlogger.hpp	(revision a80f4195d731fd366a976130725a3e131376108f)
@@ -0,0 +1,40 @@
+/*
+ * errorLogger.hpp
+ *
+ *  Created on: Oct 19, 2009
+ *      Author: metzler
+ */
+
+#ifndef ERRORLOGGER_HPP_
+#define ERRORLOGGER_HPP_
+
+#include <iosfwd>
+
+#include "Patterns/Singleton.hpp"
+
+using namespace std;
+
+class Verbose;
+
+class errorLogger : public Singleton<errorLogger>{
+  friend class Singleton<errorLogger>;
+public :
+  static ostream *nix;
+  static int verbosity;
+
+  static bool DoOutput();
+  static void setVerbosity(int verbosityLevel);
+  static int getVerbosity();
+
+protected:
+  /** Do not call this constructor directly, use getInstance() instead. */
+  errorLogger();
+  /** Do not call this destructor directly, use purgeInstance() instead. */
+  ~errorLogger();
+
+};
+
+ostream& operator<<(class errorLogger&l, const Verbose& ost);
+ostream& operator<<(class errorLogger*l, const Verbose& ost);
+
+#endif /* ERRORLOGGER_HPP_ */
Index: src/fast_functions.hpp
===================================================================
--- src/fast_functions.hpp	(revision a80f4195d731fd366a976130725a3e131376108f)
+++ src/fast_functions.hpp	(revision a80f4195d731fd366a976130725a3e131376108f)
@@ -0,0 +1,36 @@
+/*
+ * fast_functions.hpp
+ *
+ *  Created on: Apr 1, 2010
+ *      Author: crueger
+ */
+
+#ifndef FAST_FUNCTIONS_HPP_
+#define FAST_FUNCTIONS_HPP_
+
+/**
+ * !@file
+ * This file contains several functions that need to be very fast and which are inlined for this
+ * reason.
+ *
+ * Warning: do not forget inline keyword for functions in this file to avoid multiple definitions!
+ */
+
+/********************************* Functions ************************************************/
+
+/*************************** Templatized functions ************************************/
+
+/** Flips two values.
+ * \param x first value
+ * \param y second value
+ */
+template <typename T>
+inline void flip(T &x, T &y)
+{
+  T tmp;
+  tmp = x;
+  x = y;
+  y = tmp;
+};
+
+#endif /* FAST_FUNCTIONS_HPP_ */
Index: src/logger.cpp
===================================================================
--- src/logger.cpp	(revision a80f4195d731fd366a976130725a3e131376108f)
+++ src/logger.cpp	(revision a80f4195d731fd366a976130725a3e131376108f)
@@ -0,0 +1,100 @@
+/*
+ * Project: MoleCuilder
+ * Description: creates and alters molecular systems
+ * Copyright (C)  2010 University of Bonn. All rights reserved.
+ * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
+ */
+
+/*
+ * logger.cpp
+ *
+ *  Created on: Oct 19, 2009
+ *      Author: metzler
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "MemDebug.hpp"
+
+#include <fstream>
+#include <iostream>
+#include "logger.hpp"
+#include "Verbose.hpp"
+#include "Patterns/Singleton_impl.hpp"
+
+
+int logger::verbosity = 2;
+ostream* logger::nix = NULL;
+
+/**
+ * Constructor. Do not use this function. Use getInstance() instead.
+ *
+ * \return logger instance
+ */
+logger::logger()
+{
+  nix = new ofstream("/dev/null");
+};
+
+/**
+ * Destructor. Better use purgeInstance().
+ */
+logger::~logger()
+{
+  delete nix;
+}
+
+CONSTRUCT_SINGLETON(logger)
+
+/**
+ * Sets the verbosity.
+ *
+ * \param verbosityLevel verbosity
+ */
+void logger::setVerbosity(int verbosityLevel) {
+  verbosity = verbosityLevel;
+}
+
+/**
+ * Gets the verbosity.
+ *
+ * \return verbosity level
+ */
+int logger::getVerbosity()
+{
+  return verbosity;
+}
+
+/**
+ * Operator for the Binary(arg) call.
+ * Constructs temporary a Verbose class object, wherein the Binary is stored.
+ * Then << is called, which calls Binary's print which adds the tabs and logs
+ * the stream.
+ * \param &ost stream to extend
+ * \param &m pointer to created Binary object
+ * \return &ost
+ */
+ostream& operator<<(class logger& l, const Verbose& v)
+{
+  int verbosityLevel = l.verbosity;
+  l.nix->clear();
+  if (v.DoOutput(verbosityLevel)) {
+    v.print(cout);
+    return cout;
+  } else
+    return *l.nix;
+};
+ostream& operator<<(class logger* l, const Verbose& v)
+{
+  int verbosityLevel = l->verbosity;
+  l->nix->clear();
+  if (v.DoOutput(verbosityLevel)) {
+    v.print(cout);
+    return cout;
+  } else
+    return *l->nix;
+};
+
Index: src/logger.hpp
===================================================================
--- src/logger.hpp	(revision a80f4195d731fd366a976130725a3e131376108f)
+++ src/logger.hpp	(revision a80f4195d731fd366a976130725a3e131376108f)
@@ -0,0 +1,39 @@
+/*
+ * logger.hpp
+ *
+ *  Created on: Oct 19, 2009
+ *      Author: metzler
+ */
+
+#ifndef LOGGER_HPP_
+#define LOGGER_HPP_
+
+#include <iosfwd>
+
+#include "Patterns/Singleton.hpp"
+
+using namespace std;
+
+class Verbose;
+
+class logger : public Singleton<logger> {
+  friend class Singleton<logger>;
+public :
+  static ostream *nix;
+  static int verbosity;
+
+  static bool DoOutput();
+  static void setVerbosity(int verbosityLevel);
+  static int getVerbosity();
+
+protected:
+  /** Do not call this constructor directly, use getInstance() instead. */
+  logger();
+  /** Do not call this destructor directly, use purgeInstance() instead. */
+  ~logger();
+};
+
+ostream& operator<<(class logger&l, const Verbose& ost);
+ostream& operator<<(class logger*l, const Verbose& ost);
+
+#endif /* LOGGER_HPP_ */
Index: src/toString.hpp
===================================================================
--- src/toString.hpp	(revision a80f4195d731fd366a976130725a3e131376108f)
+++ src/toString.hpp	(revision a80f4195d731fd366a976130725a3e131376108f)
@@ -0,0 +1,139 @@
+/* \file toString.hpp
+ *
+ * contains template functions that allow for casting various types to strings.
+ *
+ *  Created on: Nov 14, 2010
+ *      Author: heber
+ */
+
+#ifndef TOSTRING_HPP_
+#define TOSTRING_HPP_
+
+#include <iostream>
+#include <string>
+#include <sstream>
+
+#include <list>
+#include <map>
+#include <set>
+#include <vector>
+
+/** Converter for any class to string.
+ * We use default conversion via stringstream as suggested by [Stroustrup].
+ * \param _&_object reference to object to convert to string.
+ * \return string converted \a _object
+ */
+template <class T> std::string toString(T const &_object)
+{
+  std::stringstream s;
+  s << _object;
+  return s.str();
+}
+
+/** Converter for a string to any class
+ * We use default conversion via stringstream as suggested by [Stroustrup].
+ * \param _&_object reference to object to convert.
+ * \return converted \a _object of templated type
+ */
+template <class T> struct ConvertTo {
+  T operator()(std::string _object) {
+    std::stringstream s;
+    T object;
+    s << _object;
+    s >> object;
+    return object;
+  }
+};
+
+
+/** Operator for output to std::ostream operator of an std::list of arbitrary
+ * type.
+ * @param ost output stream
+ * @param vector list of types to output
+ * @return ost output stream
+ */
+template <class T> std::ostream & operator<<(std::ostream &ost, const std::list< T > &_vector)
+{
+  ost << "( ";
+  for (typename std::list< T >::const_iterator iter = _vector.begin();
+      iter != _vector.end();
+      ++iter)
+    ost << *iter << "; ";
+  ost << ")";
+  return ost;
+}
+
+
+/** Operator for output to std::ostream operator of an std::map of arbitrary
+ * type.
+ * @param ost output stream
+ * @param vector map of types to output
+ * @return ost output stream
+ */
+template <class T, class S> std::ostream & operator<<(std::ostream &ost, const std::map< T, S > &_vector)
+{
+  ost << "{ ";
+  for (typename std::map< T, S >::const_iterator iter = _vector.begin();
+      iter != _vector.end();
+      ++iter)
+    ost << "(" << iter->first << ")=>(" << iter->second << "); ";
+  ost << "}";
+  return ost;
+}
+
+
+/** Operator for output to std::ostream operator of an std::multimap of arbitrary
+ * type.
+ * @param ost output stream
+ * @param multimap map of types to output
+ * @return ost output stream
+ */
+template <class T, class S> std::ostream & operator<<(std::ostream &ost, const std::multimap< T, S > &_vector)
+{
+  ost << "{ ";
+  for (typename std::multimap< T, S >::const_iterator iter = _vector.begin();
+      iter != _vector.end();
+      ++iter)
+    ost << "(" << iter->first << ")=>(" << iter->second << "); ";
+  ost << "}";
+  return ost;
+}
+
+
+/** Operator for output to std::ostream operator of an std::set of arbitrary
+ * type.
+ * @param ost output stream
+ * @param set list of types to output
+ * @return ost output stream
+ */
+template <class T> std::ostream & operator<<(std::ostream &ost, const std::set< T > &_vector)
+{
+  ost << "( ";
+  for (typename std::set< T >::const_iterator iter = _vector.begin();
+      iter != _vector.end();
+      ++iter)
+    ost << *iter << "; ";
+  ost << ")";
+  return ost;
+}
+
+
+/** Operator for output to std::ostream operator of an std::vector of arbitrary
+ * type.
+ * @param ost output stream
+ * @param vector vector of types to output
+ * @return ost output stream
+ */
+template <class T> std::ostream & operator<<(std::ostream &ost, const std::vector< T > &_vector)
+{
+  ost << "( ";
+  for (typename std::vector< T >::const_iterator iter = _vector.begin();
+      iter != _vector.end();
+      ++iter)
+    ost << *iter << "; ";
+  ost << ")";
+  return ost;
+}
+
+
+#endif /* TOSTRING_HPP_ */
Index: src/unittests/InfoUnitTest.cpp
===================================================================
--- src/unittests/InfoUnitTest.cpp	(revision a80f4195d731fd366a976130725a3e131376108f)
+++ src/unittests/InfoUnitTest.cpp	(revision a80f4195d731fd366a976130725a3e131376108f)
@@ -0,0 +1,63 @@
+/*
+ * Project: MoleCuilder
+ * Description: creates and alters molecular systems
+ * Copyright (C)  2010 University of Bonn. All rights reserved.
+ * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
+ */
+
+/*
+ * InfoUnitTest.cpp
+ *
+ *  Created on: Nov 25, 2009
+ *      Author: heber
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+using namespace std;
+
+#include <cppunit/CompilerOutputter.h>
+#include <cppunit/extensions/TestFactoryRegistry.h>
+#include <cppunit/ui/text/TestRunner.h>
+
+#include <iostream>
+#include <stdio.h>
+
+#include "Info.hpp"
+#include "Log.hpp"
+
+#include "InfoUnitTest.hpp"
+
+#ifdef HAVE_TESTRUNNER
+#include "UnitTestMain.hpp"
+#endif /*HAVE_TESTRUNNER*/
+
+/********************************************** Test classes **************************************/
+
+// Registers the fixture into the 'registry'
+CPPUNIT_TEST_SUITE_REGISTRATION( InfoTest );
+
+
+void InfoTest::setUp()
+{
+};
+
+
+void InfoTest::tearDown()
+{
+  logger::purgeInstance();
+};
+
+/** UnitTest for FunctionTest().
+ */
+void InfoTest::FunctionTest()
+{
+  const char *msg = __func__;
+  class Info test(msg);
+
+  CPPUNIT_ASSERT_EQUAL( msg , test.FunctionName );
+  CPPUNIT_ASSERT_EQUAL( 1, test.verbosity );
+};
Index: src/unittests/InfoUnitTest.hpp
===================================================================
--- src/unittests/InfoUnitTest.hpp	(revision a80f4195d731fd366a976130725a3e131376108f)
+++ src/unittests/InfoUnitTest.hpp	(revision a80f4195d731fd366a976130725a3e131376108f)
@@ -0,0 +1,32 @@
+/*
+ * InfoUnitTest.hpp
+ *
+ *  Created on: Nov 25, 2009
+ *      Author: heber
+ */
+
+#ifndef INFOUNITTEST_HPP_
+#define INFOUNITTEST_HPP_
+
+#include <cppunit/extensions/HelperMacros.h>
+
+class info;
+
+/********************************************** Test classes **************************************/
+
+class InfoTest : public CppUnit::TestFixture
+{
+    CPPUNIT_TEST_SUITE( InfoTest) ;
+    CPPUNIT_TEST ( FunctionTest );
+    CPPUNIT_TEST_SUITE_END();
+
+public:
+      void setUp();
+      void tearDown();
+      void FunctionTest();
+
+private:
+
+};
+
+#endif /* INFOUNITTEST_HPP_ */
Index: src/unittests/LogUnitTest.cpp
===================================================================
--- src/unittests/LogUnitTest.cpp	(revision a80f4195d731fd366a976130725a3e131376108f)
+++ src/unittests/LogUnitTest.cpp	(revision a80f4195d731fd366a976130725a3e131376108f)
@@ -0,0 +1,67 @@
+/*
+ * Project: MoleCuilder
+ * Description: creates and alters molecular systems
+ * Copyright (C)  2010 University of Bonn. All rights reserved.
+ * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
+ */
+
+/*
+ * logunittest.cpp
+ */
+
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+using namespace std;
+
+#include <cppunit/CompilerOutputter.h>
+#include <cppunit/extensions/TestFactoryRegistry.h>
+#include <cppunit/ui/text/TestRunner.h>
+
+#include "Log.hpp"
+#include "Verbose.hpp"
+
+#include "LogUnitTest.hpp"
+
+#ifdef HAVE_TESTRUNNER
+#include "UnitTestMain.hpp"
+#endif /*HAVE_TESTRUNNER*/
+
+/********************************************** Test classes **************************************/
+
+// Registers the fixture into the 'registry'
+CPPUNIT_TEST_SUITE_REGISTRATION( LogTest );
+
+
+void LogTest::setUp()
+{
+};
+
+void LogTest::tearDown()
+{
+  logger::purgeInstance();
+  errorLogger::purgeInstance();
+};
+
+/**
+ * UnitTest for log()
+ */
+void LogTest::logTest()
+{
+  logger::getInstance().setVerbosity(2);
+  DoLog(0) && (Log() << Verbose(0) << "Verbosity level is set to 2." << endl);
+  DoLog(0) && (Log() << Verbose(0) << "Test level 0" << endl);
+  DoLog(1) && (Log() << Verbose(1) << "Test level 1" << endl);
+  DoLog(2) && (Log() << Verbose(2) << "Test level 2" << endl);
+  DoLog(3) && (Log() << Verbose(3) << "Test level 3" << endl);
+  DoLog(4) && (Log() << Verbose(4) << "Test level 4" << endl);
+
+  DoLog(0) && (Log() << Verbose(0) << "Output a log message." << endl);
+  DoeLog(0) && (eLog()<< Verbose(0) << "Output an error message." << endl);
+  setVerbosity(3);
+  DoLog(4) && (Log() << Verbose(4) << "This should not be printed." << endl);
+  DoeLog(4) && (eLog()<< Verbose(4) << "This should not be printed." << endl);
+};
Index: src/unittests/LogUnitTest.hpp
===================================================================
--- src/unittests/LogUnitTest.hpp	(revision a80f4195d731fd366a976130725a3e131376108f)
+++ src/unittests/LogUnitTest.hpp	(revision a80f4195d731fd366a976130725a3e131376108f)
@@ -0,0 +1,26 @@
+/*
+ * logunittest.hpp
+ */
+
+#ifndef LOGTEST_HPP_
+#define LOGTEST_HPP_
+
+#include <cppunit/extensions/HelperMacros.h>
+
+
+/********************************************** Test classes **************************************/
+
+class LogTest : public CppUnit::TestFixture
+{
+    CPPUNIT_TEST_SUITE( LogTest) ;
+    CPPUNIT_TEST ( logTest );
+    CPPUNIT_TEST_SUITE_END();
+
+public:
+    void setUp();
+    void tearDown();
+
+    void logTest();
+};
+
+#endif /* LOGTEST_HPP_ */
Index: src/unittests/Makefile.am
===================================================================
--- src/unittests/Makefile.am	(revision a80f4195d731fd366a976130725a3e131376108f)
+++ src/unittests/Makefile.am	(revision a80f4195d731fd366a976130725a3e131376108f)
@@ -0,0 +1,62 @@
+# PLEASE adhere to the alphabetical ordering in this Makefile!
+# Also indentation by a single tab
+
+SUBDIRS = \
+	../Patterns/unittests
+
+INCLUDES = -I$(top_srcdir)/src
+
+AM_LDFLAGS = $(CPPUNIT_LIBS) -ldl
+AM_CXXFLAGS = $(CPPUNIT_CFLAGS)
+AM_CPPFLAGS = ${BOOST_CPPFLAGS}
+
+TESTS = \
+  InfoUnitTest \
+  LogUnitTest
+
+check_PROGRAMS = $(TESTS) 
+noinst_PROGRAMS = $(TESTS) TestRunner
+
+BOOST_LIB = $(BOOST_LDFLAGS) $(BOOST_MPL_LIB) $(BOOST_PROGRAM_OPTIONS_LIB) $(BOOST_FILESYSTEM_LIB) $(BOOST_SYSTEM_LIB) $(BOOST_THREAD_LIB)
+TESTLIBS = \
+	../libCodePatterns-@CODEPATTERNS_API_VERSION@.la \
+	$(BOOST_LIB)
+
+TESTSOURCES = \
+  ../Patterns/unittests/CacheableUnitTest.cpp \
+  ../Patterns/unittests/ObserverUnitTest.cpp \
+  ../Patterns/unittests/RegistryUnitTest.cpp \
+  ../Patterns/unittests/SingletonUnitTest.cpp \
+  InfoUnitTest.cpp \
+  LogUnitTest.cpp
+
+TESTHEADERS = \
+  ../Patterns/unittests/CacheableUnitTest.hpp \
+  ../Patterns/unittests/ObserverUnitTest.hpp \
+  ../Patterns/unittests/RegistryUnitTest.hpp \
+  ../Patterns/unittests/SingletonUnitTest.hpp \
+  InfoUnitTest.hpp \
+  LogUnitTest.hpp
+	
+
+InfoUnitTest_SOURCES = $(top_srcdir)/src/unittests/UnitTestMain.cpp \
+	InfoUnitTest.cpp \
+	InfoUnitTest.hpp 
+InfoUnitTest_LDADD = ${TESTLIBS}
+
+LogUnitTest_SOURCES = $(top_srcdir)/src/unittests/UnitTestMain.cpp \
+	LogUnitTest.cpp \
+	LogUnitTest.hpp
+LogUnitTest_LDADD = ${TESTLIBS}
+
+
+TestRunner_SOURCES = TestRunnerMain.cpp \
+	$(TESTSOURCES) \
+	$(TESTHEADERS) \
+	../Patterns/Cachable.hpp \
+	../Patterns/Observer.cpp \
+	../Patterns/Observer.hpp \
+	../Patterns/ObserverIterator.hpp
+TestRunner_LDADD = ${TESTLIBS}
+
+#AUTOMAKE_OPTIONS = parallel-tests
Index: src/unittests/TestRunnerMain.cpp
===================================================================
--- src/unittests/TestRunnerMain.cpp	(revision a80f4195d731fd366a976130725a3e131376108f)
+++ src/unittests/TestRunnerMain.cpp	(revision a80f4195d731fd366a976130725a3e131376108f)
@@ -0,0 +1,31 @@
+/*
+ * Project: MoleCuilder
+ * Description: creates and alters molecular systems
+ * Copyright (C)  2010 University of Bonn. All rights reserved.
+ * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
+ */
+
+/*
+ * TestRunnerMain.cpp
+ *
+ *  Created on: Feb 25, 2010
+ *      Author: heber
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#ifdef HAVE_ECUT
+// give the main function its correct name
+#define CPPUNIT_MAIN main
+// include the TestRunnerClient file containing the main class
+#include "../../../TestRunnerClient.h"
+#include "../../../TestRunnerClient.cpp"
+
+#else
+
+#include "unittests/UnitTestMain.cpp"
+
+#endif /* HAVE_ECUT */
Index: src/unittests/UnitTestMain.cpp
===================================================================
--- src/unittests/UnitTestMain.cpp	(revision a80f4195d731fd366a976130725a3e131376108f)
+++ src/unittests/UnitTestMain.cpp	(revision a80f4195d731fd366a976130725a3e131376108f)
@@ -0,0 +1,44 @@
+/*
+ * Project: MoleCuilder
+ * Description: creates and alters molecular systems
+ * Copyright (C)  2010 University of Bonn. All rights reserved.
+ * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
+ */
+
+/*
+ * UnitTestMain.cpp
+ *
+ *  Created on: Feb 24, 2010
+ *      Author: heber
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <cppunit/CompilerOutputter.h>
+#include <cppunit/extensions/TestFactoryRegistry.h>
+#include <cppunit/ui/text/TestRunner.h>
+
+/********************************************** Main routine **************************************/
+
+int main(int argc, char **argv)
+{
+  // Get the top level suite from the registry
+  CppUnit::Test *suite = CppUnit::TestFactoryRegistry::getRegistry().makeTest();
+
+  // Adds the test to the list of test to run
+  CppUnit::TextUi::TestRunner runner;
+  runner.addTest( suite );
+
+  // Change the default outputter to a compiler error format outputter
+  runner.setOutputter( new CppUnit::CompilerOutputter( &runner.result(),
+                                                       std::cerr ) );
+  // Run the tests.
+  bool wasSucessful = runner.run();
+
+  // Return error code 1 if the one of test failed.
+  return wasSucessful ? 0 : 1;
+};
+
Index: f
===================================================================
--- wtf	(revision 03f3edc5a67d300bd8afcb0c04a2ad9f16d12dd5)
+++ 	(revision )
@@ -1,1 +1,0 @@
-test
