Index: src/Actions/MapOfActions.cpp
===================================================================
--- src/Actions/MapOfActions.cpp	(revision ba741882931cf414d8a361ce994b9e69acca3497)
+++ src/Actions/MapOfActions.cpp	(revision ab9a271cb834ee7a2ab0b27a13e8cb1df70f6566)
@@ -20,6 +20,9 @@
 #include <iostream>
 
+#include "atom.hpp"
 #include "CommandLineParser.hpp"
+#include "element.hpp"
 #include "log.hpp"
+#include "molecule.hpp"
 #include "verbose.hpp"
 
@@ -266,76 +269,88 @@
 
   // value types for the actions
-  TypeMap["add-atom"] = Element;
-  TypeMap["bond-file"] = String;
-  TypeMap["bond-table"] = String;
-  TypeMap["boundary"] = Vector;
-  TypeMap["center-in-box"] = Box;
-  TypeMap["change-box"] = Box;
-  TypeMap["change-element"] = Element;
-  TypeMap["change-molname"] = String;
-  TypeMap["convex-envelope"] = Molecule;
-  TypeMap["default-molname"] = String;
-  TypeMap["depth-first-search"] = Double;
-  TypeMap["element-db"] = String;
-  TypeMap["fastparsing"] = Boolean;
-  TypeMap["fill-molecule"] = String;
-  TypeMap["fragment-mol"] = String;
-  TypeMap["input"] = String;
-  TypeMap["linear-interpolate"] = String;
-  TypeMap["molecular-volume"] = Molecule;
-  TypeMap["nonconvex-envelope"] = Molecule;
-  TypeMap["output"] = None;
-  TypeMap["parse-xyz"] = String;
-  TypeMap["pair-correlation"] = String;
-  TypeMap["principal-axis-system"] = Molecule;
-  TypeMap["remove-atom"] = Atom;
-  TypeMap["remove-sphere"] = Double;
-  TypeMap["repeat-box"] = Vector;
-  TypeMap["rotate-to-pas"] = Molecule;
-  TypeMap["save-adjacency"] = String;
-  TypeMap["save-bonds"] = String;
-  TypeMap["save-temperature"] = String;
-  TypeMap["scale-box"] = Vector;
-  TypeMap["set-basis"] = String;
-  TypeMap["set-output"] = ListOfString;
-  TypeMap["subgraph-dissect"] = None;
-  TypeMap["suspend-in-water"] = Double;
-  TypeMap["translate-mol"] = Vector;
-  TypeMap["verlet-integrate"] = String;
-  TypeMap["verbose"] = Integer;
+  TypeMap["add-atom"] = &typeid(element);
+  TypeMap["bond-file"] = &typeid(std::string);
+  TypeMap["bond-table"] = &typeid(std::string);
+  TypeMap["boundary"] = &typeid(VectorValue);
+  TypeMap["center-in-box"] = &typeid(BoxValue);
+  TypeMap["change-box"] = &typeid(BoxValue);
+  TypeMap["change-element"] = &typeid(element);
+  TypeMap["change-molname"] = &typeid(std::string);
+  TypeMap["convex-envelope"] = &typeid(molecule);
+  TypeMap["default-molname"] = &typeid(std::string);
+  TypeMap["depth-first-search"] = &typeid(double);
+  TypeMap["element-db"] = &typeid(std::string);
+  TypeMap["fastparsing"] = &typeid(bool);
+  TypeMap["fill-molecule"] = &typeid(std::string);
+  TypeMap["fragment-mol"] = &typeid(std::string);
+  TypeMap["input"] = &typeid(std::string);
+  TypeMap["linear-interpolate"] = &typeid(std::string);
+  TypeMap["molecular-volume"] = &typeid(molecule);
+  TypeMap["nonconvex-envelope"] = &typeid(molecule);
+  TypeMap["output"] = &typeid(void);
+  TypeMap["parse-xyz"] = &typeid(std::string);
+  TypeMap["pair-correlation"] = &typeid(std::string);
+  TypeMap["principal-axis-system"] = &typeid(molecule);
+  TypeMap["remove-atom"] = &typeid(atom);
+  TypeMap["remove-sphere"] = &typeid(double);
+  TypeMap["repeat-box"] = &typeid(VectorValue);
+  TypeMap["rotate-to-pas"] = &typeid(molecule);
+  TypeMap["save-adjacency"] = &typeid(std::string);
+  TypeMap["save-bonds"] = &typeid(std::string);
+  TypeMap["save-temperature"] = &typeid(std::string);
+  TypeMap["scale-box"] = &typeid(VectorValue);
+  TypeMap["set-basis"] = &typeid(std::string);
+  TypeMap["set-output"] = &typeid(std::vector<std::string>);
+  TypeMap["subgraph-dissect"] = &typeid(void);
+  TypeMap["suspend-in-water"] = &typeid(double);
+  TypeMap["translate-mol"] = &typeid(VectorValue);
+  TypeMap["verlet-integrate"] = &typeid(std::string);
+  TypeMap["verbose"] = &typeid(int);
 
   // value types for the values
-  TypeMap["atom-by-id"] = Atom;
-  TypeMap["bin-output-file"] = String;
-  TypeMap["bin-end"] = Double;
-  TypeMap["bin-start"] = Double;
-  TypeMap["bin-width"] = Double;
-  TypeMap["convex-file"] = String;
-  TypeMap["distance"] = Double;
-  TypeMap["distances"] = Vector;
-  TypeMap["DoRotate"] = Boolean;
-  TypeMap["element"] = Element;
-  TypeMap["elements"] = ListOfElements;
-  TypeMap["end-step"] = Integer;
-  TypeMap["id-mapping"] = Boolean;
-  TypeMap["length"] = Double;
-  TypeMap["lengths"] = Vector;
-  TypeMap["MaxDistance"] = Double;
-  TypeMap["molecule-by-id"] = Molecule;
-  TypeMap["molecule-by-name"] = String;
-  TypeMap["nonconvex-file"] = String;
-  TypeMap["order"] = Integer;
-  TypeMap["output-file"] = String;
-  TypeMap["periodic"] = Boolean;
-  TypeMap["position"] = Vector;
-  TypeMap["sphere-radius"] = Double;
-  TypeMap["start-step"] = Integer;
+  TypeMap["atom-by-id"] = &typeid(atom);
+  TypeMap["bin-output-file"] = &typeid(std::string);
+  TypeMap["bin-end"] = &typeid(double);
+  TypeMap["bin-start"] = &typeid(double);
+  TypeMap["bin-width"] = &typeid(double);
+  TypeMap["convex-file"] = &typeid(std::string);
+  TypeMap["distance"] = &typeid(double);
+  TypeMap["distances"] = &typeid(VectorValue);
+  TypeMap["DoRotate"] = &typeid(bool);
+  TypeMap["element"] = &typeid(element);
+  TypeMap["elements"] = &typeid(std::vector<element *>);
+  TypeMap["end-step"] = &typeid(int);
+  TypeMap["id-mapping"] = &typeid(bool);
+  TypeMap["length"] = &typeid(double);
+  TypeMap["lengths"] = &typeid(VectorValue);
+  TypeMap["MaxDistance"] = &typeid(double);
+  TypeMap["molecule-by-id"] = &typeid(molecule);
+  TypeMap["molecule-by-name"] = &typeid(std::string);
+  TypeMap["nonconvex-file"] = &typeid(std::string);
+  TypeMap["order"] = &typeid(int);
+  TypeMap["output-file"] = &typeid(std::string);
+  TypeMap["periodic"] = &typeid(bool);
+  TypeMap["position"] = &typeid(VectorValue);
+  TypeMap["sphere-radius"] = &typeid(double);
+  TypeMap["start-step"] = &typeid(int);
+
+  TypeEnumMap[&typeid(int)] = Integer;
+  TypeEnumMap[&typeid(double)] = Double;
+  TypeEnumMap[&typeid(bool)] = Boolean;
+  TypeEnumMap[&typeid(std::string)] = String;
+  TypeEnumMap[&typeid(atom)] = Atom;
+  TypeEnumMap[&typeid(element)] = Element;
+  TypeEnumMap[&typeid(std::vector<element *>)] = ListOfElements;
+  TypeEnumMap[&typeid(molecule)] = Molecule;
+  TypeEnumMap[&typeid(VectorValue)] = Vector;
+  TypeEnumMap[&typeid(BoxValue)] = Box;
+
 
   // default values for any action that needs one (always string!)
-  DefaultValue["bin-width"] = "0.5";
-  DefaultValue["fastparsing"] = "0";
-  DefaultValue["atom-by-id"] = "-1";
-  DefaultValue["molecule-by-id"] = "-1";
-  DefaultValue["periodic"] = "0";
+  CurrentValue["bin-width"] = "0.5";
+  CurrentValue["fastparsing"] = "0";
+  CurrentValue["atom-by-id"] = "-1";
+  CurrentValue["molecule-by-id"] = "-1";
+  CurrentValue["periodic"] = "0";
 
   // put action into each menu category
@@ -537,5 +552,4 @@
 }
 
-
 /** Adds all options to the CommandLineParser.
  *
@@ -548,5 +562,5 @@
       if (hasValue(*OptionRunner)) {
         DoLog(0) && (Log() << Verbose(0) << "Adding option " << *OptionRunner << " with type " << TypeMap[*OptionRunner] << " to CommandLineParser." << endl);
-           switch((enum OptionTypes) TypeMap[*OptionRunner]) {
+           switch(TypeEnumMap[TypeMap[*OptionRunner]]) {
           default:
           case None:
@@ -558,6 +572,6 @@
             ListRunner->second->add_options()
               (getKeyAndShortForm(*OptionRunner).c_str(),
-                  DefaultValue.find(*OptionRunner) != DefaultValue.end() ?
-                        po::value< bool >()->default_value(atoi(DefaultValue[*OptionRunner].c_str())) :
+                  CurrentValue.find(*OptionRunner) != CurrentValue.end() ?
+                        po::value< bool >()->default_value(atoi(CurrentValue[*OptionRunner].c_str())) :
                         po::value< bool >(),
                   getDescription(*OptionRunner).c_str())
@@ -574,6 +588,6 @@
             ListRunner->second->add_options()
               (getKeyAndShortForm(*OptionRunner).c_str(),
-                  DefaultValue.find(*OptionRunner) != DefaultValue.end() ?
-                        po::value< int >()->default_value(atoi(DefaultValue[*OptionRunner].c_str())) :
+                  CurrentValue.find(*OptionRunner) != CurrentValue.end() ?
+                        po::value< int >()->default_value(atoi(CurrentValue[*OptionRunner].c_str())) :
                         po::value< int >(),
                   getDescription(*OptionRunner).c_str())
@@ -590,6 +604,6 @@
             ListRunner->second->add_options()
               (getKeyAndShortForm(*OptionRunner).c_str(),
-                  DefaultValue.find(*OptionRunner) != DefaultValue.end() ?
-                        po::value< double >()->default_value(atof(DefaultValue[*OptionRunner].c_str())) :
+                  CurrentValue.find(*OptionRunner) != CurrentValue.end() ?
+                        po::value< double >()->default_value(atof(CurrentValue[*OptionRunner].c_str())) :
                         po::value< double >(),
                   getDescription(*OptionRunner).c_str())
@@ -606,6 +620,6 @@
             ListRunner->second->add_options()
               (getKeyAndShortForm(*OptionRunner).c_str(),
-                  DefaultValue.find(*OptionRunner) != DefaultValue.end() ?
-                        po::value< std::string >()->default_value(DefaultValue[*OptionRunner]) :
+                  CurrentValue.find(*OptionRunner) != CurrentValue.end() ?
+                        po::value< std::string >()->default_value(CurrentValue[*OptionRunner]) :
                         po::value< std::string >(),
                   getDescription(*OptionRunner).c_str())
@@ -622,6 +636,6 @@
             ListRunner->second->add_options()
               (getKeyAndShortForm(*OptionRunner).c_str(),
-                  DefaultValue.find(*OptionRunner) != DefaultValue.end() ?
-                        po::value< int >()->default_value(atoi(DefaultValue[*OptionRunner].c_str())) :
+                  CurrentValue.find(*OptionRunner) != CurrentValue.end() ?
+                        po::value< int >()->default_value(atoi(CurrentValue[*OptionRunner].c_str())) :
                         po::value< int >(),
                   getDescription(*OptionRunner).c_str())
@@ -638,6 +652,6 @@
             ListRunner->second->add_options()
               (getKeyAndShortForm(*OptionRunner).c_str(),
-                  DefaultValue.find(*OptionRunner) != DefaultValue.end() ?
-                        po::value< int >()->default_value(atoi(DefaultValue[*OptionRunner].c_str())) :
+                  CurrentValue.find(*OptionRunner) != CurrentValue.end() ?
+                        po::value< int >()->default_value(atoi(CurrentValue[*OptionRunner].c_str())) :
                         po::value< int >(),
                   getDescription(*OptionRunner).c_str())
@@ -654,6 +668,6 @@
             ListRunner->second->add_options()
               (getKeyAndShortForm(*OptionRunner).c_str(),
-                  DefaultValue.find(*OptionRunner) != DefaultValue.end() ?
-                        po::value< int >()->default_value(atoi(DefaultValue[*OptionRunner].c_str())) :
+                  CurrentValue.find(*OptionRunner) != CurrentValue.end() ?
+                        po::value< int >()->default_value(atoi(CurrentValue[*OptionRunner].c_str())) :
                         po::value< int >(),
                   getDescription(*OptionRunner).c_str())
@@ -751,7 +765,7 @@
  * \return type of the action
  */
-enum MapOfActions::OptionTypes MapOfActions::getValueType(string actionname)
-{
-  return TypeMap[actionname];
+std::string MapOfActions::getValueType(string actionname)
+{
+  return TypeMap[actionname]->name();
 }
 
Index: src/Actions/MapOfActions.hpp
===================================================================
--- src/Actions/MapOfActions.hpp	(revision ba741882931cf414d8a361ce994b9e69acca3497)
+++ src/Actions/MapOfActions.hpp	(revision ab9a271cb834ee7a2ab0b27a13e8cb1df70f6566)
@@ -14,10 +14,14 @@
 #include <map>
 #include <set>
+#include <typeinfo>
 
 class MapOfActionsTest;
 
+#include "Exceptions/IllegalTypeException.hpp"
 #include "Patterns/Singleton.hpp"
 
 namespace po = boost::program_options;
+
+using boost::lexical_cast;
 
 /** Central class for adding functionality to the code.
@@ -136,5 +140,5 @@
   bool hasValue(std::string actionname);
   bool isShortFormPresent(std::string shortform);
-  enum OptionTypes getValueType(std::string actionname);
+  std::string  getValueType(std::string actionname);
 
   std::set<std::string> generic;
@@ -150,4 +154,21 @@
   void populateActions();
 
+  template<typename T> void queryCurrentValue(const char * name, T &_T)
+  {
+    if (typeid( T ) == *TypeMap[name])  // constructor of type_info is private, hence can only store by ref or ptr
+      _T = lexical_cast<T>(CurrentValue[name].c_str());
+    else
+      throw IllegalTypeException(__FILE__,__LINE__);
+  }
+
+  template<class T> void setCurrentValue(const char * name, T &_T)
+  {
+    if (typeid( T ) == *TypeMap[name])  // constructor of type_info is private, hence can only store by ref or ptr
+      CurrentValue[name] = std::string(_T);
+    else
+      throw IllegalTypeException(__FILE__,__LINE__);
+  }
+
+
 private:
   // private constructor and destructor
@@ -159,8 +180,9 @@
 
   // map of the action names and their description
-  std::map<std::string, std::string> DefaultValue;
+  std::map<std::string, std::string> CurrentValue;
   std::map<std::string, std::string> DescriptionMap;
   std::map<std::string, std::string> ShortFormMap;
-  std::map<std::string, enum OptionTypes > TypeMap;
+  std::map<std::string, const std::type_info * > TypeMap;
+  std::map<const std::type_info *, enum OptionTypes > TypeEnumMap;
 };
 
Index: src/Exceptions/IllegalTypeException.cpp
===================================================================
--- src/Exceptions/IllegalTypeException.cpp	(revision ab9a271cb834ee7a2ab0b27a13e8cb1df70f6566)
+++ src/Exceptions/IllegalTypeException.cpp	(revision ab9a271cb834ee7a2ab0b27a13e8cb1df70f6566)
@@ -0,0 +1,21 @@
+/*
+ * IllegalTypeException.cpp
+ *
+ *  Created on: Jun 25, 2010
+ *      Author: crueger
+ */
+
+#include "IllegalTypeException.hpp"
+
+using namespace std;
+
+IllegalTypeException::IllegalTypeException(string _file, int _line) :
+  MathException(_file,_line)
+{}
+
+IllegalTypeException::~IllegalTypeException() throw ()
+{}
+
+const char* IllegalTypeException::what() const throw(){
+  return "Illegal type in cast";
+}
Index: src/Exceptions/IllegalTypeException.hpp
===================================================================
--- src/Exceptions/IllegalTypeException.hpp	(revision ab9a271cb834ee7a2ab0b27a13e8cb1df70f6566)
+++ src/Exceptions/IllegalTypeException.hpp	(revision ab9a271cb834ee7a2ab0b27a13e8cb1df70f6566)
@@ -0,0 +1,22 @@
+/*
+ * IllegalTypeException.hpp
+ *
+ *  Created on: Jun 25, 2010
+ *      Author: crueger
+ */
+
+#ifndef ILLEGALTYPEEXCEPTION_HPP_
+#define ILLEGALTYPEEXCEPTION_HPP_
+
+#include "Exceptions/CustomException.hpp"
+
+class IllegalTypeException : public CustomException
+{
+public:
+  IllegalTypeException(std::string _file, int _line);
+  virtual ~IllegalTypeException() throw ();
+
+  virtual const char* what() const throw();
+};
+
+#endif /* ILLEGALTYPEEXCEPTION_HPP_ */
Index: src/Makefile.am
===================================================================
--- src/Makefile.am	(revision ba741882931cf414d8a361ce994b9e69acca3497)
+++ src/Makefile.am	(revision ab9a271cb834ee7a2ab0b27a13e8cb1df70f6566)
@@ -78,4 +78,5 @@
 
 EXCEPTIONSOURCE = Exceptions/CustomException.cpp \
+				  Exceptions/IllegalTypeException.cpp \
 				  Exceptions/LinearDependenceException.cpp \
 				  Exceptions/MathException.cpp \
@@ -85,4 +86,5 @@
 				  
 EXCEPTIONHEADER = Exceptions/CustomException.hpp \
+				  Exceptions/IllegalTypeException.hpp \
 				  Exceptions/LinearDependenceException.hpp \
 				  Exceptions/MathException.hpp \
