Index: src/Box_BoundaryConditions.cpp
===================================================================
--- src/Box_BoundaryConditions.cpp	(revision dd067a91bd5ce81d3092ebda02eb4e1f20978a8f)
+++ src/Box_BoundaryConditions.cpp	(revision dd067a91bd5ce81d3092ebda02eb4e1f20978a8f)
@@ -0,0 +1,197 @@
+/*
+ * Project: MoleCuilder
+ * Description: creates and alters molecular systems
+ * Copyright (C)  2012 University of Bonn. All rights reserved.
+ * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
+ */
+
+/*
+ * Box_BoundaryConditions.cpp
+ *
+ *  Created on: Jan 2, 2012
+ *      Author: heber
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "CodePatterns/MemDebug.hpp"
+
+#include <boost/tokenizer.hpp>
+#include <boost/algorithm/string/trim.hpp>
+#include <iostream>
+#include <string>
+
+#include "Box_BoundaryConditions.hpp"
+
+#include "CodePatterns/Assert.hpp"
+#include "CodePatterns/Log.hpp"
+#include "CodePatterns/Range.hpp"
+#include "LinearAlgebra/defs.hpp"
+
+/** Constructor of class BCContainer.
+ *
+ * Fills member BCContainer::ConverterBiMap and
+ * BCContainer::ReConverterBiMap.
+ */
+BoundaryConditions::BCContainer::BCContainer()
+{
+  // fill static conversion maps when empty
+  ASSERT(ConverterBiMap.size() == ReConverterBiMap.size(),
+      "BCContainer::BoundaryConditions() - internal string<->enum maps differ in size.");
+  if (ConverterBiMap.empty()) {
+    // hither
+    ConverterBiMap.insert( std::make_pair(BoundaryConditions::Wrap, std::string("Wrap")) );
+    ConverterBiMap.insert( std::make_pair(BoundaryConditions::Bounce, std::string("Bounce")) );
+    ConverterBiMap.insert( std::make_pair(BoundaryConditions::Ignore, std::string("Ignore")) );
+    // thither
+    ReConverterBiMap.insert( std::make_pair(std::string("Wrap"), BoundaryConditions::Wrap) );
+    ReConverterBiMap.insert( std::make_pair(std::string("Bounce"), BoundaryConditions::Bounce) );
+    ReConverterBiMap.insert( std::make_pair(std::string("Ignore"), BoundaryConditions::Ignore) );
+  }
+  ASSERT(ConverterBiMap.size() ==  (size_t)(BoundaryConditions::MAX_BoundaryCondition_t),
+      "BCContainer::BoundaryConditions() - internal string<->enum map has not the same number of elements "
+      +toString(ConverterBiMap.size())+" as the enum "
+      +toString((size_t)(MAX_BoundaryCondition_t))+".");
+
+  // fill us with default values
+  resize(NDIM, BoundaryConditions::Wrap);
+}
+
+/** Destructor of class BCContainer.
+ *
+ */
+BoundaryConditions::BCContainer::~BCContainer()
+{
+  ConverterBiMap.clear();
+  ReConverterBiMap.clear();
+}
+
+/** Getter for a all boundary conditions.
+ *
+ * @return vector with the boundary conditions
+ */
+const BoundaryConditions::Conditions_t & BoundaryConditions::BCContainer::get() const
+{
+  return (*this);
+}
+
+/** Getter for the boundary condition of a specific axis.
+ *
+ * @param index axis
+ * @return boundary condition of this axis.
+ */
+const BoundaryConditions::BoundaryCondition_t BoundaryConditions::BCContainer::get(size_t index) const
+{
+#ifndef NDEBUG
+  range<size_t> AllowedRange(0, this->size());
+  ASSERT(AllowedRange.isInRange(index),
+      "BCContainer::get() - index "+toString(index)+" out of bounds "
+      +toString(AllowedRange)+".");
+#endif
+  return operator[](index);
+}
+
+/** Setter for all boundary conditions.
+ *
+ * @param _conditions vector with all conditions to set.
+ */
+void BoundaryConditions::BCContainer::set(const BoundaryConditions::Conditions_t &_conditions)
+{
+  ASSERT(_conditions.size() == this->size(),
+      "BCContainer::set() - given vector of conditions and this have unequal size.");
+  for (size_t i = 0; i < _conditions.size(); ++i)
+    (*this)[i] = _conditions[i];
+}
+
+void BoundaryConditions::BCContainer::set(size_t index, const BoundaryConditions::BoundaryCondition_t _condition)
+{
+#ifndef NDEBUG
+  range<size_t> AllowedRange(0, this->size());
+  ASSERT(AllowedRange.isInRange(index),
+      "BCContainer::set() - index "+toString(index)+" out of bounds "
+      +toString(AllowedRange)+".");
+#endif
+  (*this)[index] = _condition;
+}
+
+/** Converter from enum to string.
+ *
+ * @param condition enum
+ * @return name of the num
+ */
+const std::string & BoundaryConditions::BCContainer::getName(const BoundaryConditions::BoundaryCondition_t &condition) const
+{
+  ASSERT( ((condition >= (BoundaryConditions::BoundaryCondition_t)0) && (condition < BoundaryConditions::MAX_BoundaryCondition_t)),
+      "BCContainer::getName() - enum "+toString(condition)+" is not a valid enum.");
+  EnumToStringMap::const_iterator iter = ConverterBiMap.find(condition);
+  ASSERT(iter != ConverterBiMap.end(),
+      "BCContainer::getEnum() - enum "+toString(condition)+" is unknown for any enum name.");
+  return iter->second;
+}
+
+/** Converter from string to enum.
+ *
+ * @param condition name of the condition
+ * @return enum index
+ */
+const BoundaryConditions::BoundaryCondition_t & BoundaryConditions::BCContainer::getEnum(const std::string &condition) const
+{
+  StringToEnumMap::const_iterator iter = ReConverterBiMap.find(condition);
+  ASSERT( iter != ReConverterBiMap.end(),
+      "BCContainer::getEnum() - name "+condition+" is unknown for any enum.");
+  return iter->second;
+}
+
+/** Output routine for class BCContainer to stream.
+ *
+ * @param out stream to print to
+ * @param t instance of BCContainer.
+ * @return stream for concatenation
+ */
+std::ostream &operator<<(std::ostream &out, const BoundaryConditions::BCContainer &t)
+{
+  for (BoundaryConditions::BCContainer::const_iterator iter = t.begin(); iter != t.end(); ++iter) {
+    if (iter != t.begin())
+      out << ", ";
+    out << t.getName(*iter);
+  }
+  return out;
+}
+
+/** Input routine for class BCContainer from stream.
+ *
+ *  We expect input as comma-separated list with NDIM values.
+ *
+ * @param in input stream
+ * @param t instance of BCContainer to set
+ * @return input stream for concatenation
+ */
+std::istream &operator>>(std::istream &in, BoundaryConditions::BCContainer &t)
+{
+  // read from stream till semicolon or end
+  std::stringbuf sbuf;
+  in.get(sbuf, ';');
+
+  // tokenize
+  typedef boost::tokenizer< boost::char_separator<char> > tokens;
+  BoundaryConditions::Conditions_t conditions;
+  boost::char_separator<char> commasep(",");
+  // it is imperative to copy the content of the stringbuffer, otherwise we'll
+  // get strange bug where 'Wrap' != 'Wrap' and so on.
+  std::string line(sbuf.str());
+  tokens tok(line, commasep);
+  for(tokens::iterator iter=tok.begin(); iter!=tok.end();++iter) {
+    // remove leading and trailing white space
+    std::string condition(*iter);
+    boost::trim(condition);
+    conditions.push_back(t.getEnum(condition));
+  }
+
+  // set
+  t.set(conditions);
+
+  return in;
+}
Index: src/Box_BoundaryConditions.hpp
===================================================================
--- src/Box_BoundaryConditions.hpp	(revision dd067a91bd5ce81d3092ebda02eb4e1f20978a8f)
+++ src/Box_BoundaryConditions.hpp	(revision dd067a91bd5ce81d3092ebda02eb4e1f20978a8f)
@@ -0,0 +1,82 @@
+/*
+ * Box_BoundaryConditions.hpp
+ *
+ *  Created on: Jan 2, 2012
+ *      Author: heber
+ */
+
+#ifndef BOX_BOUNDARYCONDITIONS_HPP_
+#define BOX_BOUNDARYCONDITIONS_HPP_
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <boost/array.hpp>
+#include <iosfwd>
+#include <map>
+#include <vector>
+#include <string>
+
+#include "LinearAlgebra/defs.hpp"
+
+class Box_BoundaryConditionsTest;
+
+namespace BoundaryConditions {
+
+  //!> typedef for enumeration of boundary conditions
+  typedef enum{
+    Wrap,
+    Bounce,
+    Ignore,
+    MAX_BoundaryCondition_t
+  } BoundaryCondition_t;
+
+  //!> typedef for vector containing boundary conditions
+  typedef std::vector<BoundaryCondition_t> Conditions_t;
+
+  /** This class is a convenience wrapper for the vector of BoundaryCondition_t.
+   *
+   * Here, we place functions for easily printing the boundary conditions,
+   * converting from string to enum, and so on.
+   */
+  class BCContainer : public Conditions_t
+  {
+    //!> grant unit test access to private members
+    friend class ::Box_BoundaryConditionsTest;
+  public:
+
+    BCContainer();
+    ~BCContainer();
+
+    // getter and setter
+    const Conditions_t & get() const;
+    const BoundaryCondition_t get(size_t index) const;
+    void set(const Conditions_t &_conditions);
+    void set(size_t index, const BoundaryCondition_t _condition);
+
+    // converter
+    const std::string & getName(const BoundaryCondition_t &condition) const;
+    const BoundaryCondition_t &getEnum(const std::string &condition) const;
+
+  private:
+    //!> typedef for the internal enum to string map
+    typedef std::map<BoundaryCondition_t, std::string> EnumToStringMap;
+    //!> instance of the enum to string conversion bimap
+    EnumToStringMap ConverterBiMap;
+
+    //!> typedef for the internal string to enum map
+    typedef std::map<std::string, BoundaryCondition_t> StringToEnumMap;
+    //!> instance of the string to enum conversion bimap
+    StringToEnumMap ReConverterBiMap;
+  };
+
+} /* namespace BoundaryConditions */
+
+std::ostream &operator<<(std::ostream &out, const BoundaryConditions::BCContainer &t);
+
+std::istream &operator>>(std::istream &in, BoundaryConditions::BCContainer &t);
+
+
+#endif /* BOX_BOUNDARYCONDITIONS_HPP_ */
Index: src/Makefile.am
===================================================================
--- src/Makefile.am	(revision 44f53e999bbb8a07d6654248774d7a3bb802ecaa)
+++ src/Makefile.am	(revision dd067a91bd5ce81d3092ebda02eb4e1f20978a8f)
@@ -155,4 +155,5 @@
   ${TESSELATIONSOURCE} \
   Box.cpp \
+  Box_BoundaryConditions.cpp \
   config.cpp \
   Formula.cpp \
@@ -175,4 +176,5 @@
   ${TESSELATIONHEADER} \
   Box.hpp \
+  Box_BoundaryConditions.hpp \
   config.hpp \
   Formula.hpp \
Index: src/unittests/Box_BoundaryConditionsUnitTest.cpp
===================================================================
--- src/unittests/Box_BoundaryConditionsUnitTest.cpp	(revision dd067a91bd5ce81d3092ebda02eb4e1f20978a8f)
+++ src/unittests/Box_BoundaryConditionsUnitTest.cpp	(revision dd067a91bd5ce81d3092ebda02eb4e1f20978a8f)
@@ -0,0 +1,156 @@
+/*
+ * Project: MoleCuilder
+ * Description: creates and alters molecular systems
+ * Copyright (C)  2012 University of Bonn. All rights reserved.
+ * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
+ */
+
+/*
+ * Box_BoundaryConditionsUnitTest.cpp
+ *
+ *  Created on: Jan 2, 2012
+ *      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 <sstream>
+
+#include "Box_BoundaryConditions.hpp"
+#include "CodePatterns/Assert.hpp"
+#include "LinearAlgebra/defs.hpp"
+
+#include "Box_BoundaryConditionsUnitTest.hpp"
+
+#ifdef HAVE_TESTRUNNER
+#include "UnitTestMain.hpp"
+#endif /*HAVE_TESTRUNNER*/
+
+/********************************************** Test classes **************************************/
+
+// Registers the fixture into the 'registry'
+CPPUNIT_TEST_SUITE_REGISTRATION( Box_BoundaryConditionsTest );
+
+void Box_BoundaryConditionsTest::setUp(){
+  // failing asserts should be thrown
+  ASSERT_DO(Assert::Throw);
+
+  CPPUNIT_ASSERT_NO_THROW( bc = new BoundaryConditions::BCContainer );
+}
+
+void Box_BoundaryConditionsTest::tearDown()
+{
+  delete bc;
+}
+
+void Box_BoundaryConditionsTest::getTest()
+{
+  // check default values
+  for (size_t index = 0; index < NDIM; ++index)
+    CPPUNIT_ASSERT_EQUAL( BoundaryConditions::Wrap, bc->get(index));
+
+  // check throw
+#ifndef NDEBUG
+  std::cout << "The following assertions are intended and do not represent a failure of the test.\n";
+  CPPUNIT_ASSERT_THROW( bc->get(4), Assert::AssertionFailure );
+  CPPUNIT_ASSERT_THROW( bc->get(-1), Assert::AssertionFailure );
+#endif
+}
+
+void Box_BoundaryConditionsTest::setTest()
+{
+  // set to other values
+  bc->set(1, BoundaryConditions::Ignore);
+  bc->set(2, BoundaryConditions::Bounce);
+
+  // check that is not Wrap anymore
+  CPPUNIT_ASSERT_EQUAL( BoundaryConditions::Ignore, bc->get(1) );
+  CPPUNIT_ASSERT_EQUAL( BoundaryConditions::Bounce, bc->get(2) );
+
+  // check throw
+#ifndef NDEBUG
+  std::cout << "The following assertions are intended and do not represent a failure of the test.\n";
+  CPPUNIT_ASSERT_THROW( bc->set(4, BoundaryConditions::Wrap), Assert::AssertionFailure );
+  CPPUNIT_ASSERT_THROW( bc->set(-1, BoundaryConditions::Wrap), Assert::AssertionFailure );
+#endif
+
+  // set all at once
+  BoundaryConditions::Conditions_t conditions(3, BoundaryConditions::Wrap);
+
+  // check throw
+  conditions.resize(NDIM+1, BoundaryConditions::Wrap);
+#ifndef NDEBUG
+  std::cout << "The following assertion is intended and does not represent a failure of the test.\n";
+  CPPUNIT_ASSERT_THROW( bc->set(conditions), Assert::AssertionFailure );
+#endif
+  conditions.resize(NDIM-1, BoundaryConditions::Wrap);
+#ifndef NDEBUG
+  std::cout << "The following assertion is intended and does not represent a failure of the test.\n";
+  CPPUNIT_ASSERT_THROW( bc->set(conditions), Assert::AssertionFailure );
+#endif
+}
+
+void Box_BoundaryConditionsTest::outputTest()
+{
+  std::stringstream outstream;
+  outstream << *bc;
+  CPPUNIT_ASSERT( outstream.str() == std::string("Wrap, Wrap, Wrap"));
+}
+
+void Box_BoundaryConditionsTest::converterTest()
+{
+  // enum to string
+  for (size_t index = (size_t)0; index < (size_t)BoundaryConditions::MAX_BoundaryCondition_t;index++)
+    CPPUNIT_ASSERT_EQUAL(
+        bc->ConverterBiMap[(BoundaryConditions::BoundaryCondition_t)index],
+        bc->getName((BoundaryConditions::BoundaryCondition_t)index) );
+  // check throw
+#ifndef NDEBUG
+  std::cout << "The following assertion is intended and does not represent a failure of the test.\n";
+  CPPUNIT_ASSERT_THROW( bc->getName(BoundaryConditions::MAX_BoundaryCondition_t), Assert::AssertionFailure );
+#endif
+
+  // enum to string
+  CPPUNIT_ASSERT_EQUAL( BoundaryConditions::Wrap, bc->getEnum(std::string("Wrap")) );
+  CPPUNIT_ASSERT_EQUAL( BoundaryConditions::Bounce, bc->getEnum(std::string("Bounce")) );
+  CPPUNIT_ASSERT_EQUAL( BoundaryConditions::Ignore, bc->getEnum(std::string("Ignore")) );
+  // check throw
+#ifndef NDEBUG
+  std::cout << "The following assertion is intended and does not represent a failure of the test.\n";
+  CPPUNIT_ASSERT_THROW( bc->getEnum("Unknown"), Assert::AssertionFailure );
+#endif
+}
+
+void Box_BoundaryConditionsTest::inputTest()
+{
+  // set by string
+  std::stringstream inputstream(" Bounce, Wrap, Ignore");
+  CPPUNIT_ASSERT_NO_THROW( inputstream >> *bc );
+
+  // check
+  CPPUNIT_ASSERT_EQUAL( BoundaryConditions::Bounce, bc->get(0) );
+  CPPUNIT_ASSERT_EQUAL( BoundaryConditions::Wrap, bc->get(1) );
+  CPPUNIT_ASSERT_EQUAL( BoundaryConditions::Ignore, bc->get(2) );
+
+  // check throw
+  std::stringstream invalidstream1("Bounce");
+  std::stringstream invalidstream2("Bounce, Bounce, Wrap, Ignore");
+#ifndef NDEBUG
+  std::cout << "The following assertions are intended and do not represent a failure of the test.\n";
+  CPPUNIT_ASSERT_THROW( invalidstream1 >> *bc, Assert::AssertionFailure );
+  CPPUNIT_ASSERT_THROW( invalidstream2 >> *bc, Assert::AssertionFailure );
+#endif
+
+  // check that all is still the same
+  CPPUNIT_ASSERT_EQUAL( BoundaryConditions::Bounce, bc->get(0) );
+  CPPUNIT_ASSERT_EQUAL( BoundaryConditions::Wrap, bc->get(1) );
+  CPPUNIT_ASSERT_EQUAL( BoundaryConditions::Ignore, bc->get(2) );
+}
+
Index: src/unittests/Box_BoundaryConditionsUnitTest.hpp
===================================================================
--- src/unittests/Box_BoundaryConditionsUnitTest.hpp	(revision dd067a91bd5ce81d3092ebda02eb4e1f20978a8f)
+++ src/unittests/Box_BoundaryConditionsUnitTest.hpp	(revision dd067a91bd5ce81d3092ebda02eb4e1f20978a8f)
@@ -0,0 +1,43 @@
+/*
+ * Box_BoundaryConditionsUnitTest.hpp
+ *
+ *  Created on: Jan 2, 2012
+ *      Author: heber
+ */
+
+#ifndef BOXUNITTEST_HPP_
+#define BOXUNITTEST_HPP_
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+
+#include <cppunit/extensions/HelperMacros.h>
+
+class Box_BoundaryConditionsTest : public CppUnit::TestFixture
+{
+  CPPUNIT_TEST_SUITE( Box_BoundaryConditionsTest );
+  CPPUNIT_TEST ( getTest );
+  CPPUNIT_TEST ( setTest );
+  CPPUNIT_TEST ( outputTest );
+  CPPUNIT_TEST ( converterTest );
+  CPPUNIT_TEST ( inputTest );
+  CPPUNIT_TEST_SUITE_END();
+
+public:
+  void setUp();
+  void tearDown();
+
+  void getTest();
+  void setTest();
+  void outputTest();
+  void converterTest();
+  void inputTest();
+
+private:
+  BoundaryConditions::BCContainer *bc;
+};
+
+#endif /* BOXUNITTEST_HPP_ */
Index: src/unittests/Makefile.am
===================================================================
--- src/unittests/Makefile.am	(revision 44f53e999bbb8a07d6654248774d7a3bb802ecaa)
+++ src/unittests/Makefile.am	(revision dd067a91bd5ce81d3092ebda02eb4e1f20978a8f)
@@ -28,4 +28,5 @@
 GENERALTESTS = \
   BoxUnitTest \
+  Box_BoundaryConditionsTest \
   FormulaUnittest \
   ListOfBondsUnitTest \
@@ -80,4 +81,5 @@
 	stubs/ObserverStub.cpp \
   BoxUnitTest.cpp \
+	Box_BoundaryConditionsUnitTest.cpp \
   FormulaUnitTest.cpp \
   ListOfBondsUnitTest.cpp \
@@ -101,4 +103,5 @@
 	stubs/ObserverStub.hpp \
   BoxUnitTest.hpp \
+	Box_BoundaryConditionsUnitTest.hpp \
   FormulaUnitTest.hpp \
   ListOfBondsUnitTest.hpp \
@@ -116,4 +119,13 @@
 	../libMolecuilderHelpers.la \
 	$(top_builddir)/LinearAlgebra/src/LinearAlgebra/libLinearAlgebra.la
+
+Box_BoundaryConditionsTest_SOURCES = $(top_srcdir)/src/unittests/UnitTestMain.cpp \
+	Box_BoundaryConditionsUnitTest.cpp \
+	Box_BoundaryConditionsUnitTest.hpp \
+	../Box_BoundaryConditions.cpp \
+	../Box_BoundaryConditions.hpp
+Box_BoundaryConditionsTest_LDADD = \
+	${CodePatterns_LIBS} \
+	$(BOOST_LIB)
 
 FormulaUnittest_SOURCES = $(top_srcdir)/src/unittests/UnitTestMain.cpp \
