Index: /bdm/config/UIbuilder_test.cfg
===================================================================
--- /bdm/config/UIbuilder_test.cfg (revision 244)
+++ /bdm/config/UIbuilder_test.cfg (revision 246)
@@ -7,6 +7,17 @@
 test2:
 {
+type= "internal";
+path="int";
+};
+test3:
+{
 type= "external";
 filename = "UIbuilder_test_ex.cfg";
 path="test2";
 };
+int:
+{
+type= "test2";
+a= 1;
+S= "yeah!!!";
+};
Index: /bdm/config/UIbuilder_test.cpp
===================================================================
--- /bdm/config/UIbuilder_test.cpp (revision 244)
+++ /bdm/config/UIbuilder_test.cpp (revision 246)
@@ -65,15 +65,16 @@
 int main(){
 
-Config C;
-C.readFile("UIbuilder_test.cfg");
-Setting& S=C.getRoot();;
+UIFile UI("UIbuilder_test.cfg");
 
 cls* Cls;
-UIbuild(S["test"],&Cls);
+UIbuild(UI.lookup("test"),&Cls);
 cls* Cls2;
-UIbuild(S["test2"],&Cls2);
+UIbuild(UI.lookup("test2"),&Cls2);
+cls* Cls3;
+UIbuild(UI.lookup("test3"),&Cls3);
 
 Cls->print();
 Cls2->print();
+Cls3->print();
 return 0;
 }
Index: /bdm/config/uibuilder.cpp
===================================================================
--- /bdm/config/uibuilder.cpp (revision 244)
+++ /bdm/config/uibuilder.cpp (revision 246)
@@ -18,5 +18,19 @@
 	
 };
+UIREGISTER(UIexternal);
 
-UIREGISTER(UIexternal);
+void UIinternal::build(Setting &S, void** result) const{
+	try {	
+		Setting* Stmp = &S;
+		do {Stmp=&(Stmp->getParent());} while (!Stmp->isRoot());
+		Setting& intS=Stmp->lookup((const char*)S["path"]);
+		UIbuild(intS,result);
+	}
+	catch (...) { it_error("Internal field " + string(S.getPath()) + " not valid");
+	}
+	
+};
+UIREGISTER(UIinternal);
+
+
 //UIexternal* UIexternal_instance =new UIexternal();
Index: /bdm/config/libconfig-1.3.1/libconfig.h++
===================================================================
--- /bdm/config/libconfig-1.3.1/libconfig.h++ (revision 245)
+++ /bdm/config/libconfig-1.3.1/libconfig.h++ (revision 246)
@@ -327,4 +327,14 @@
     inline unsigned int getSourceLine() const throw()
     { return(config_setting_source_line(_setting)); }
+
+	inline Setting& lookup(const char *path) const
+  throw(SettingNotFoundException)
+{
+  config_setting_t *s = config_lookup(_setting->config, path);
+  if(! s)
+    throw SettingNotFoundException(path);
+
+  return(Setting::wrapSetting(s));
+}
   };
 
Index: /bdm/config/uibuilder.h
===================================================================
--- /bdm/config/uibuilder.h (revision 243)
+++ /bdm/config/uibuilder.h (revision 246)
@@ -7,15 +7,105 @@
 using namespace libconfig;
 using namespace itpp;
-	
-class UI: public Setting{
+using namespace std;
+
+#define CHECK_UITYPE(S,Type) it_assert_debug(S.getType()==Setting::Type, string("Wrong input path \"")+string(S.getPath())+string("\""));
+#define UIREGISTER(UI) UI* UI##_global_instance = new UI();
+
+////////// GLOBAL VAriables
+
+class UIbuilder;
+//! Internal structure mapping strings to UIBuilder objects
+typedef map<const string, const UIbuilder*> UImap;
+extern UImap __uimap__;
+
+class UIFile : public Config{
 	public:
-		template<class Num_T>
-		Vec<Num_T>& getvec(Setting& S){
-			itpp_assert_debug(S.getType()==Setting::TypeArray,"Wrong input on line:"+S.getSourceLine());
-			Vec<Num_T> tmp;	
-			tmp.set_size(S.getLength());
-			for (int =0;i<S.getLength();i++){tmp[i]=(Num_T)(S[i]);}
+	UIFile(const char * fname):Config(){
+		try{Config::readFile(fname);} 
+		catch (ParseException& P) {
+			char msg[200];
+			sprintf(msg,"Error in file %s  on line %d.", fname, P.getLine());
+			it_error(msg);
+		} 
+		catch (FileIOException f) {it_error("File " + string(fname) + " not found");} 
+	}
+};
+
+/*!\brief Builds computational object from a UserInfo structure
+
+Return value is a pointer to the created object (memory management issue?)
+*/
+class UIbuilder {
+	protected:
+		static const UIbuilder* theinstance;
+	vec getvec ( Setting& S ) {
+		CHECK_UITYPE(S,TypeArray);
+		vec tmp;
+		tmp.set_size ( S.getLength() );
+		for ( int i=0;i<S.getLength();i++ ) {
+			switch (S[i].getType()) {
+				case Setting::TypeFloat :
+					tmp[i]=double(S[i]);break;
+				case Setting::TypeInt :
+					tmp[i]=int(S[i]);break;
+				case Setting::TypeBoolean :
+					tmp[i]=bool(S[i]);break;
+				default: it_error("libconfig error?");
+			} 
 		}
-}
+		return tmp;
+	};
+	vec getivec ( Setting& S ) {
+		CHECK_UITYPE(S,TypeArray);
+		vec tmp;
+		tmp.set_size ( S.getLength() );
+		for ( int i=0;i<S.getLength();i++ ) {
+			switch (S[i].getType()) {
+				case Setting::TypeFloat :
+					tmp[i]=double(S[i]);break;
+				case Setting::TypeInt :
+					tmp[i]=int(S[i]);break;
+				case Setting::TypeBoolean :
+					tmp[i]=bool(S[i]);break;
+					default: it_error("libconfig error?");
+			} 
+		}
+		return tmp;
+	};
+	public:
+		UIbuilder(const string &typ){__uimap__.insert(make_pair(typ,this));}
+		virtual void build(Setting &S, void** result) const {it_error("Calling uibuilder basic" );};
+};
+
+class UIexternal:public UIbuilder{
+	public:
+		UIexternal():UIbuilder("external"){}
+		void build(Setting &S, void** result) const;
+};
+
+class UIinternal:public UIbuilder{
+	public:
+		UIinternal():UIbuilder("internal"){}
+		void build(Setting &S, void** result) const;
+};
+
+template<class T>
+void UIbuild(Setting &S, T** ret){
+	CHECK_UITYPE(S,TypeGroup);
+	T* tmp;
+	it_assert_debug(S.exists("type"), string(S.getPath())+" is not a valid UI!");
+		
+	const string typ=S["type"];
+	UImap::const_iterator iter = __uimap__.find( typ );
+	if( iter == __uimap__.end()) {
+		it_error("UI of type \"" + typ + "\" is not registered!");
+	}
+	else {const UIbuilder* is= iter->second; is->build(S,reinterpret_cast<void**>(&tmp));}
+	// make assignment
+	*ret=tmp;
+};
+
+
+Setting& UILoad(const char* fname);
 
 #endif UIBUILD
Index: /bdm/config/CMakeLists.txt
===================================================================
--- /bdm/config/CMakeLists.txt (revision 244)
+++ /bdm/config/CMakeLists.txt (revision 246)
@@ -1,2 +1,5 @@
+	INCLUDE_DIRECTORIES(libconfig-1.3.1)
+	LINK_DIRECTORIES(libconfig-1.3.1/.libs)
+
 add_library(libui uibuilder.cpp uibuilder.h)
 EXEC(UIbuilder_test config++ libui)
