Index: src/Potentials/Particles/Particle.cpp
===================================================================
--- src/Potentials/Particles/Particle.cpp	(revision ff09f309bdcecdd5c2f8fb409678e75dd20e73dc)
+++ src/Potentials/Particles/Particle.cpp	(revision ff09f309bdcecdd5c2f8fb409678e75dd20e73dc)
@@ -0,0 +1,240 @@
+/*
+ * Project: MoleCuilder
+ * Description: creates and alters molecular systems
+ * Copyright (C)  2013 Frederik Heber. All rights reserved.
+ * 
+ *
+ *   This file is part of MoleCuilder.
+ *
+ *    MoleCuilder 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.
+ *
+ *    MoleCuilder 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 MoleCuilder.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/*
+ * Particle.cpp
+ *
+ *  Created on: May 13, 2013
+ *      Author: heber
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "CodePatterns/MemDebug.hpp"
+
+#include "Particle.hpp"
+
+#include <boost/assign.hpp>
+#include <boost/lexical_cast.hpp>
+#include <boost/tokenizer.hpp>
+#include <iostream>
+#include <iterator>
+#include <string>
+
+#include "CodePatterns/Assert.hpp"
+
+#include "Element/element.hpp"
+#include "Element/periodentafel.hpp"
+#include "Potentials/Exceptions.hpp"
+#include "Potentials/Particles/ParticleRegistry.hpp"
+
+using namespace boost::assign;
+
+std::vector<std::string> getParameterNames()
+{
+  std::vector<std::string> tempnames;
+  tempnames += "particle_type", "element_name", "sigma", "epsilon", "sigma14", "epsilon14", "mass", "free", "charge";
+  return tempnames;
+}
+
+const std::vector<std::string> Particle::ParameterNames = getParameterNames();
+
+Particle::Particle(
+    const periodentafel &_periode,
+    const std::string &_token,
+    const atomicNumber_t &_number) :
+    name(_token),
+    periode(_periode),
+    charge(0.),
+    mass(0.),
+    dof(3),
+    atomic_number(_number),
+    sigma(0.),
+    epsilon(0.),
+    sigma_14(0.),
+    epsilon_14(0.)
+{
+  ParticleRegistry::getInstance().registerInstance(this);
+}
+
+std::string Particle::findFreeName(
+    const periodentafel &_periode,
+    const atomicNumber_t &_number) const
+{
+  const element *e = _periode.FindElement(_number);
+  ASSERT (e != NULL,
+      "Particle::findFreeName() - cannot find element with number "
+      +toString(_number)+".");
+  bool FoundFlag = false;
+  size_t index = 1;
+  std::string returnname;
+  while(!FoundFlag) {
+    returnname = e->getSymbol()+toString(index);
+    FoundFlag = !ParticleRegistry::getInstance().isPresentByName(returnname);
+  }
+  return returnname;
+}
+
+Particle::Particle(
+    const periodentafel &_periode,
+    const atomicNumber_t &_number) :
+    name(findFreeName(_periode, _number)),
+    periode(_periode),
+    charge(0.),
+    mass(0.),
+    dof(3),
+    atomic_number(_number),
+    sigma(0.),
+    epsilon(0.),
+    sigma_14(0.),
+    epsilon_14(0.)
+{
+  ParticleRegistry::getInstance().registerInstance(this);
+}
+
+void Particle::stream_to(std::ostream &ost) const
+{
+  // check stream
+  if (ost.bad())
+    throw SerializablePotentialException();
+
+  /// print parameter key
+  ost << "\tparticle:";
+  /// print name and values
+  ost << "\tparticle_type=" << getName();
+  ost << ",\telement_name=" << getElement();
+  ost << ",\tsigma=" << sigma;
+  ost << ",\tepsilon=" << epsilon;
+  ost << ",\tsigma14=" << sigma_14;
+  ost << ",\tepsilon14=" << epsilon_14;
+  ost << ",\tmass=" << mass;
+  ost << ",\tfree=" << dof;
+  ost << ",\tcharge=" << charge;
+  ost << std::endl;
+}
+
+size_t Particle::lookupParameterName(const std::string &name) const
+{
+  std::vector<std::string>::const_iterator iter =
+      std::find(ParameterNames.begin(), ParameterNames.end(), name);
+  if (iter == ParameterNames.end())
+    return -1;
+  else
+    return std::distance(ParameterNames.begin(), iter);
+}
+
+void Particle::stream_from(std::istream &ist)
+{
+  // check stream
+  if (ist.bad())
+    throw SerializablePotentialException();
+
+  // read in full line
+  std::string linestring;
+  getline(ist, linestring);
+  const std::string whitespace(" \t");
+  const size_t strBegin = linestring.find_first_not_of(whitespace);
+  const size_t colonpos = linestring.find(":");
+  if ((strBegin == std::string::npos) || (colonpos == std::string::npos) ||
+      (linestring.substr(strBegin, colonpos-1) != std::string("particle")))
+    throw SerializablePotentialMissingValueException()
+        << SerializablePotentialKey(std::string("particle"));
+
+  // tokenize by ","
+  typedef boost::tokenizer<boost::char_separator<char> > tokenizer;
+  boost::char_separator<char> pairsep(",\t ;");
+  boost::char_separator<char> keyvaluesep("=");
+  std::string remainderstring(linestring.substr(colonpos+1));
+  tokenizer tokens(remainderstring, pairsep); //skip colon
+
+  // step through each token
+  for (tokenizer::iterator tok_iter = tokens.begin();
+    tok_iter != tokens.end(); ++tok_iter) {
+    const std::string &keyvalue = *tok_iter;
+    tokenizer keyvaluetoken(keyvalue, keyvaluesep);
+    tokenizer::iterator keyvalue_iter = keyvaluetoken.begin();
+    const std::string &key = *keyvalue_iter;
+    const std::string &value = *keyvalue_iter;
+
+    const size_t index = lookupParameterName(key);
+
+    switch((parameters_t)index) {
+    case e_particle_type:
+      const_cast<std::string &>(name) = value;
+      break;
+    case e_element_name:
+      setElement(value);
+      break;
+    case e_sigma:
+      sigma = boost::lexical_cast<double>(value);
+      break;
+    case e_epsilon:
+      epsilon = boost::lexical_cast<double>(value);
+      break;
+    case e_sigma_14:
+      sigma_14 = boost::lexical_cast<double>(value);
+      break;
+    case e_epsilon_14:
+      epsilon_14 = boost::lexical_cast<double>(value);
+      break;
+    case e_mass:
+      mass = boost::lexical_cast<double>(value);
+      break;
+    case e_free:
+      dof = boost::lexical_cast<unsigned int>(value);
+      break;
+    case e_charge:
+      charge = boost::lexical_cast<double>(value);
+      break;
+    default:
+      ASSERT(0, "Particle::stream_from() - unknown index "
+          +toString(index)+".");
+      break;
+    }
+  }
+}
+
+std::ostream& operator<<(std::ostream &ost, const Particle &p)
+{
+  p.stream_to(ost);
+  return ost;
+}
+
+std::string Particle::getElement() const
+{
+  std::string returnstring;
+  const element *e = periode.FindElement(atomic_number);
+  if (e != NULL)
+    returnstring = e->getSymbol();
+
+  return returnstring;
+}
+
+void Particle::setElement(const std::string &element_name)
+{
+  const element *e = periode.FindElement(element_name);
+  if (e != NULL)
+    atomic_number = e->getAtomicNumber();
+}
Index: src/Potentials/Particles/Particle.hpp
===================================================================
--- src/Potentials/Particles/Particle.hpp	(revision ff09f309bdcecdd5c2f8fb409678e75dd20e73dc)
+++ src/Potentials/Particles/Particle.hpp	(revision ff09f309bdcecdd5c2f8fb409678e75dd20e73dc)
@@ -0,0 +1,160 @@
+/*
+ * Particle.hpp
+ *
+ *  Created on: May 13, 2013
+ *      Author: heber
+ */
+
+#ifndef PARTICLE_HPP_
+#define PARTICLE_HPP_
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <iosfwd>
+#include <string>
+#include <vector>
+
+#include "types.hpp"
+
+class periodentafel;
+
+class Particle
+{
+public:
+  /** Constructor for class Particle.
+   *
+   * Chooses token as combination of element's symbol and a number such that name is
+   * unique with registry.
+   *
+   * \param _periode reference to periodentafel for looking up element nr
+   * \param _number atomic number of particle's element
+   */
+  Particle(const periodentafel &_periode, const atomicNumber_t &_number);
+
+  /** Constructor for class Particle.
+   *
+   * \param _periode reference to periodentafel for looking up element nr
+   * \param _token unique token/name of this particle
+   * \param _number atomic number of particle's element
+   */
+  Particle(const periodentafel &_periode, const std::string &_token, const atomicNumber_t &_number);
+
+  /** Destructor for class Particle.
+   *
+   */
+  ~Particle() {}
+
+  /** Getter for the name of this Particle.
+   *
+   * This function is required such that Particle's can be stored in a registry.
+   *
+   * \return name of particle
+   */
+  const std::string& getName() const
+  { return name; }
+
+  /** Print parameters to given stream \a ost.
+   *
+   * These are virtual functions to allow for overriding and hence
+   * changing the default behavior.
+   *
+   * @param ost stream to print to
+   */
+  void stream_to(std::ostream &ost) const;
+
+  /** Parse parameters from given stream \a ist.
+   *
+   * These are virtual functions to allow for overriding and hence
+   * changing the default behavior.
+   *
+   * @param ist stream to parse from
+   */
+  void stream_from(std::istream &ist);
+
+private:
+  /** Default constructor for class Particle.
+   *
+   * \warning default constructor is private to prevent Particle without a
+   * unique name.
+   *
+   */
+  Particle();
+
+  /** Helper function to find index to a parameter name.
+   *
+   * \param name name of parameter to look up index for
+   * \return index in ParameterNames or -1 if not found
+   */
+  size_t lookupParameterName(const std::string &name) const;
+
+  /** Returns the name of the element.
+   *
+   * \return name of the particle's element
+   */
+  std::string getElement() const;
+
+  /** Setter for the particle's element.
+   *
+   * \param element_name name of particle's element, must be known to periodentafel.
+   */
+  void setElement(const std::string &element_name);
+
+  /** Finds the next free token in the registry for the given element.
+   *
+   * \param _periode reference to periodentafel for looking up element nr
+   * \param _number atomic number of particle's element
+   * \return unique token for this element
+   */
+  std::string findFreeName(
+      const periodentafel &_periode,
+      const atomicNumber_t &_number) const;
+
+private:
+  //!> token/name of this particle
+  const std::string name;
+
+  //!> reference to periodentafel to look up elements
+  const periodentafel &periode;
+
+  //!> partial charge of this particle
+  double charge;
+  //!> (effective) mass of this particle
+  double mass;
+  //!> (effective) degrees of freedom
+  unsigned int dof;
+  //!> atomic number of the particle's element
+  atomicNumber_t atomic_number;
+
+  // the following variables are due to convention in .potentials file
+  double sigma;
+  double epsilon;
+  double sigma_14;
+  double epsilon_14;
+
+  enum parameters_t {
+    e_particle_type,
+    e_element_name,
+    e_sigma,
+    e_epsilon,
+    e_sigma_14,
+    e_epsilon_14,
+    e_mass,
+    e_free,
+    e_charge,
+    MAXPARAMETERS
+  };
+
+  static const std::vector<std::string> ParameterNames;
+};
+
+/** Output stream operator for class Particle.
+ *
+ * \param ost output stream
+ * \param p Particle instance
+ */
+std::ostream& operator<<(std::ostream &ost, const Particle &p);
+
+#endif /* PARTICLE_HPP_ */
Index: src/Potentials/Particles/ParticleRegistry.cpp
===================================================================
--- src/Potentials/Particles/ParticleRegistry.cpp	(revision ff09f309bdcecdd5c2f8fb409678e75dd20e73dc)
+++ src/Potentials/Particles/ParticleRegistry.cpp	(revision ff09f309bdcecdd5c2f8fb409678e75dd20e73dc)
@@ -0,0 +1,43 @@
+/*
+ * Project: MoleCuilder
+ * Description: creates and alters molecular systems
+ * Copyright (C)  2013 Frederik Heber. All rights reserved.
+ * 
+ *
+ *   This file is part of MoleCuilder.
+ *
+ *    MoleCuilder 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.
+ *
+ *    MoleCuilder 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 MoleCuilder.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/*
+ * ParticleRegistry.cpp
+ *
+ *  Created on: May 13, 2013
+ *      Author: heber
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "CodePatterns/MemDebug.hpp"
+
+#include "Potentials/Particles/ParticleRegistry.hpp"
+
+#include "CodePatterns/Singleton_impl.hpp"
+#include "CodePatterns/Registry_impl.hpp"
+
+CONSTRUCT_SINGLETON(ParticleRegistry)
+CONSTRUCT_REGISTRY(Particle)
Index: src/Potentials/Particles/ParticleRegistry.hpp
===================================================================
--- src/Potentials/Particles/ParticleRegistry.hpp	(revision ff09f309bdcecdd5c2f8fb409678e75dd20e73dc)
+++ src/Potentials/Particles/ParticleRegistry.hpp	(revision ff09f309bdcecdd5c2f8fb409678e75dd20e73dc)
@@ -0,0 +1,39 @@
+/*
+ * ParticleRegistry.hpp
+ *
+ *  Created on: May 13, 2013
+ *      Author: heber
+ */
+
+#ifndef PARTICLEREGISTRY_HPP_
+#define PARTICLEREGISTRY_HPP_
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "CodePatterns/Registry.hpp"
+#include "CodePatterns/Singleton.hpp"
+
+#include "Potentials/Particles/Particle.hpp"
+
+/** Particle Registry.
+ *
+ * The Potential registry is a storage for any Particle instance to
+ * be retrieved by name. It is a singleton and can be called from anywhere.
+ *
+ */
+class ParticleRegistry : public Singleton<ParticleRegistry>, public Registry<Particle>
+{
+  friend class Singleton<ParticleRegistry>;
+  //friend class Registry<class Particle>;
+
+public:
+
+private:
+  ParticleRegistry() {}
+  ~ParticleRegistry() {}
+};
+
+#endif /* PARTICLEREGISTRY_HPP_ */
