Index: tests/UI/UIbuilder_test.cpp
===================================================================
--- tests/UI/UIbuilder_test.cpp (revision 278)
+++ tests/UI/UIbuilder_test.cpp (revision 344)
@@ -1,66 +1,165 @@
 #include <uibuilder.h>
+#include <string>
 
-using namespace libconfig;
+using std::string;
 using namespace std;
 using namespace bdm;
 
-class cls :public bdmroot{
-	public:
-		int a;
-		string S;
-		cls(int a0, string S0):a(a0),S(S0){};
-		virtual void print(){cout << a << " and "<< S << endl;}
-};
-class cls2: public cls{
-	public:
-	cls2(int a0, string S0):cls(a0,S0){};
-	void print(){cout << a << " or "<< S << endl;}
+class Transport : public bdmroot
+{
+public:
+	int year;
+	string manufacturer;
+
+	Transport()
+	{
+		year = 1900;
+		manufacturer = "unknown";
+	}
+
+	Transport( int year, string manufacturer )
+		: year( year ), manufacturer( manufacturer )
+	{
+	}
+
+	virtual void FromSetting( const Setting &root )
+	{
+		root.lookupValue( "year", year );
+		root.lookupValue( "manufacturer", manufacturer );
+	}
+
+	virtual void ToSetting( Setting &root ) 
+	{	
+		Setting &year_setting = root.add("year", Setting::TypeInt );
+		year_setting = year;
+
+		Setting &manufacturer_setting = root.add("manufacturer", Setting::TypeString );
+		manufacturer_setting = manufacturer;	
+	}
 };
 
-class UItest : public UIbuilder{
-	public:
-	UItest():UIbuilder("test"){}
-	bdmroot* build(Setting &S) const{
-			int a=S["a"];
-			string St;
-			S.lookupValue("S",St);
-			cls* tmp = new cls(a,St);
-			return tmp;
-	}	
+class Car : public Transport
+{
+public:
+	int kilometers;
+
+	Car() : Transport()		  
+	{
+		kilometers = 0;
+	}
+
+
+	Car( int year, string manufacturer, int kilometers )
+		: Transport( year, manufacturer ), kilometers( kilometers )
+	{
+	}
+
+	virtual void FromSetting( const Setting &root ) 
+	{	
+		Transport::FromSetting( root );
+
+		root.lookupValue( "kilometers", kilometers );
+	}
+
+	virtual void ToSetting( Setting &root ) 
+	{	
+		Transport::ToSetting( root );
+
+		Setting &kilometers_setting = root.add("kilometers", Setting::TypeInt );
+		kilometers_setting = kilometers;
+	}
+
+	string ToString()
+	{
+		stringstream stream;
+		stream << "a car made in " << year << " by " << manufacturer << ", having " << kilometers << " kilometers on the clock.";
+		return stream.str();
+	}
 };
 
-class UItest2 : public UIbuilder{
-	public:
-	UItest2():UIbuilder("test2"){}
-	bdmroot* build(Setting &S) const{
-			int a=S["a"];
-			string St;
-			S.lookupValue("S",St);
-			return  new cls2(a,St);
-	}	
-	int no(){return 2;}
+UIREGISTER(Car);
+
+class Bike : public Transport
+{
+public:
+	bool electricLights;
+	mat matr;
+
+	Bike() : Transport(), matr("2,2;3,4")
+	{
+		electricLights = false;		
+	}
+
+	Bike( int year, string manufacturer, bool electricLights )
+		: Transport( year, manufacturer ), electricLights( electricLights )
+	{
+	}
+
+	~Bike()
+	{
+	}
+
+	void FromSetting( const Setting &root ) 
+	{	
+		Transport::FromSetting( root );
+
+		root.lookupValue( "electricLights", electricLights );
+
+		UI::Get( matr, root, "matr" );
+	}
+
+	void ToSetting( Setting &root ) 
+	{	
+		Transport::ToSetting( root );
+
+		Setting &electricLights_setting = root.add("electricLights", Setting::TypeBoolean );
+		electricLights_setting = electricLights;
+
+		UI::Save( matr, root, "matr" );
+	}
+
+	string ToString()
+	{
+		stringstream stream;
+		stream << "a bike made in " << year << " by " << manufacturer;
+		if( electricLights ) stream << " with electric lights included";						
+		return stream.str();
+	}
 };
 
-UIREGISTER(UItest);
-UIREGISTER(UItest2);
-//UItest* UItest_instance = new UItest();
-//UItest2* UItest2_instance = new UItest2();
+UIREGISTER(Bike);
 
-int main(){
-UIFile UI("UIbuilder_test.cfg");
+int main()
+{	
+	/////////////////////////////////// SAVING //////////////////////////
+	/*
+	Car audi( 1998, "audi", 25000);
+	Car liaz( 1992, "liaz", 1555000);
+	Bike author( 1996, "author", true );
 
-cls* Cls;
-UIbuild(UI.lookup("test"),Cls);
-cls* Cls2;
-UIbuild(UI.lookup("test2"),Cls2);
-cls* Cls3;
-UIbuild(UI.lookup("test3"),Cls3);
+	UIFile root("UIbuilder_test.cfg");	
+	UI::Save( audi, root, "pepikovo");
+	UI::Save( liaz, root, "jardovo"); 
+	UI::Save( author, root, "ondrejovo");
+	root.Save();
 
-Cls->print();
-Cls2->print();
-Cls3->print(); 
-
-delete Cls;
-delete Cls2;
-delete Cls3;
+	cout << "all the transport means were saved correctly" << endl;				
+	getchar();
+	*/
+	
+	//////////////////////////////////// LOADING ////////////////////////////////
+	UIFile root("UIbuilder_test.cfg");	
+	root.Load();
+	Transport *pepikovo = UI::Build<Transport>( root, "pepikovo");	
+	cout << "pepikovo: " << pepikovo->ToString() << endl;		
+	Transport *jardovo = UI::Build<Transport>( root, "jardovo");	
+	cout << "jardovo: " << jardovo->ToString() << endl;		
+	Transport *ondrejovo = UI::Build<Transport>( root, "ondrejovo");	
+	cout << "ondrejovo: " << ondrejovo->ToString() << endl;		
+	Transport *elisky = UI::Build<Transport>( root, "elisky");	
+	cout << "elisky: " << elisky->ToString() << endl;		
+	Transport *kati = UI::Build<Transport>( root, "kati");	
+	cout << "kati: " << kati->ToString() << endl;		
+	getchar(); 
+	return 0;
 }
