Index: tests/testUI.cpp
===================================================================
--- tests/testUI.cpp (revision 150)
+++ tests/testUI.cpp (revision 151)
@@ -1,98 +1,251 @@
 #include "userinfo.h"
 
+//////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////// BASIC VALUED USER INFOS ///////////////////////////
+//////////////////////////////////////////////////////////////////////////////////////////////
+
+class BoolUI: public ValuedUserInfo<bool>
+{
+private:
+
+	bool* AssemblyInstance()
+	{		
+		if( value == "true" )
+			return new bool( true );
+		else
+			return new bool( false );
+	}
+
+	bool DisassemblyInstance(bool &instance)
+	{
+		if( instance )
+			value = "true";
+		else
+			value = "false";
+		return true; 
+	}
+
+public:
+
+	BoolUI()
+		: ValuedUserInfo<bool>("bool")
+	{
+	}
+};
+
+const TypedUserInfo<bool>& TypedUserInfo<bool>::instance = BoolUI();
+
+
 class IntUI: public ValuedUserInfo<int>
 {
+private:
+
+	int* AssemblyInstance()
+	{
+		return new int( atoi( value.c_str()) );
+	}
+
+	bool DisassemblyInstance(int &instance)
+	{
+		char buff[30];
+		sprintf(buff, "%d", instance );
+		value = buff;
+		return true; 
+	}
+
 public:
 	IntUI():ValuedUserInfo<int>("int")
 	{
 	}
-
-	void Build(int* &pInstance)
-	{
-		pInstance = new int( atoi( value.c_str()) );
-	}
-
-	void Absorb(int* &pInstance)
+};
+
+const TypedUserInfo<int>& TypedUserInfo<int>::instance = IntUI();
+
+
+class DoubleUI: public ValuedUserInfo<double>
+{
+private:
+
+	double* AssemblyInstance()
+	{
+		return new double( atof( value.c_str()) );
+	}
+
+	bool DisassemblyInstance(double &instance)
 	{
 		char buff[30];
-		sprintf(buff, "%d", *pInstance );
+		sprintf(buff, "%f", instance );
 		value = buff;
-	}
-};
-
-const TypedUserInfo<int>* TypedUserInfo<int>::pInstance = new IntUI();
+		return true; 
+	}
+
+public:
+	DoubleUI():ValuedUserInfo<double>("double")
+	{
+	}
+};
+
+const TypedUserInfo<double>& TypedUserInfo<double>::instance = DoubleUI();
 
 
 class StringUI: public ValuedUserInfo<string>
 {
+private:
+	string* AssemblyInstance()
+	{
+		return new string( value );
+	}
+
+	bool DisassemblyInstance(string &instance)
+	{
+		value = instance;
+		return true;
+	}
+
 public:
 	StringUI():ValuedUserInfo<string>("string")
 	{
 	}
-
-	void Build(string* &pInstance)
-	{
-		pInstance  = new string( value );
-	}
-
-	void Absorb(string* &pInstance)
-	{
-		value = *pInstance;
-	}
-};
-
-const TypedUserInfo<string>* TypedUserInfo<string>::pInstance = new StringUI();
-
-class Car
-{
-public:
-	int age;
-	string brand;
-
-	Car( int age, string brand)
-		: age( age), brand( brand)
-	{
-	}
-};
+};
+
+const TypedUserInfo<string>& TypedUserInfo<string>::instance = StringUI();
+
+//////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////// EXAMPLE CLASSES DEFINITION ////////////////////////
+//////////////////////////////////////////////////////////////////////////////////////////////
+class Transport
+{
+public:
+	const int year;
+	const string manufacturer;
+
+	Transport( int year, string manufacturer )
+		: year( year ), manufacturer( manufacturer )
+	{
+	}
+
+	virtual public void ToString() = 0;
+};
+
+class Car : public Transport
+{
+public:
+	const int kilometers;
+
+	Car( int year, string manufacturer, int kilometers )
+		: Transport( year, manufacturer ), kilometers( kilometers )
+	{
+	}
+
+	void ToString()
+	{
+		cout << "a car made in " << year << " by " << manufacturer << ", having " << kilometers << " kilometers on the clock." << endl;
+	}
+};
+
+class Bike : public Transport
+{
+public:
+	const bool electricLights;
+
+	Bike( int age, string manufacturer, bool electricLights )
+		: Transport( age, manufacturer ), electricLights( electricLights )
+	{
+	}
+
+	void ToString()
+	{
+		cout << "a bike made in " << year << " by " << manufacturer;
+		if( electricLights ) cout << " with electric lights included";						
+		cout << endl;		
+	}
+};
+
+//////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////// AND RELATED USER INFOS ////////////////////////////
+//////////////////////////////////////////////////////////////////////////////////////////////
+
 
 class CarUI: public CompoundUserInfo<Car>
 {
-public:
-	BindedType<int> age;
-	BindedType<string> brand;
-
+private:
+	BindedElement<int> year; 
+	BindedElement<int> kilometers; 
+	BindedElement<string> manufacturer; 
+public:
 	CarUI()
 		:CompoundUserInfo<Car>("car"),
-		age( this, "age" ),
-		brand( this, "brand")
-	{
-	}
-
-	void Build(Car* &pInstance)
-	{
-		if( age.pInstance == NULL ) age.pInstance = new int (0);
-		if( brand.pInstance == NULL ) brand.pInstance = new string("noname");
-		pInstance  = new Car( *age.pInstance, *brand.pInstance );
-	}
-
-	void Absorb(Car* &pInstance)
-	{
-		age.pInstance = &pInstance->age;
-		brand.pInstance = &pInstance->brand;
-	}
-};
-
-const TypedUserInfo<Car>* TypedUserInfo<Car>::pInstance = new CarUI( );
+		year( this, "year", 0 ),
+		kilometers( this, "kilometers", 0 ),
+		manufacturer( this, "manufacturer", "unknown")
+	{
+	}
+private:
+
+	Car* AssemblyInstance()
+	{
+		// assembly new instance
+		return new Car( year.value, manufacturer.value, kilometers.value );
+	}
+
+	bool DisassemblyInstance(Car& instance)
+	{
+		year.value = instance.year;
+		manufacturer.value = instance.manufacturer;
+		kilometers.value = instance.kilometers;
+		return true;
+	}
+};
+
+const TypedUserInfo<Car>& TypedUserInfo<Car>::instance = CarUI( );
+
+
+class BikeUI: public CompoundUserInfo<Bike>
+{
+private:
+	BindedElement<int> year; 
+	BindedElement<bool> lights; 
+	BindedElement<string> manufacturer; 
+public:
+	BikeUI()
+		:CompoundUserInfo<Bike>("bike"),
+		year( this, "year", 0 ),
+		lights( this, "electric_lights", false ), // jen jedno slovo!
+		manufacturer( this, "manufacturer", "unknown")
+	{
+	}
+private:
+
+	Bike* AssemblyInstance()
+	{
+		// assembly new instance
+		return new Bike( year.value, manufacturer.value, lights.value );
+	}
+
+	bool DisassemblyInstance(Bike& instance)
+	{
+		year.value = instance.year;
+		manufacturer.value = instance.manufacturer;
+		lights.value = instance.electricLights;
+		return true;
+	}
+};
+
+const TypedUserInfo<Bike>& TypedUserInfo<Bike>::instance = BikeUI( );
 
 
 int main()
 {
+	Car audi( 1998, "audi", 25000);
+	Car liaz( 1992, "liaz", 1555000);
+	Bike author( 1996, "author", true );
+
 	/////////////////////////////////// SAVING ///////////////////////////
-	Car newCar( 20, "audina" );
-
-	RootElement root("car.xml");
-	// NESLO BY TAM MISTO POINTERU PRIMO REFERENCI,
-	// NEBO TAK NECO?!?! ASI JO..!
-	if( !UserInfo::Disassembly( &newCar,root,"kara") )
+
+	RootElement root("transport.xml");
+
+	if( !UserInfo::Disassembly( audi, root, "pepikovo") 
+		|| !UserInfo::Disassembly( liaz, root, "jardovo") 
+		|| !UserInfo::Disassembly( author, root, "ondrejovo")  )
 	{
 		cout << "there was some error!" << endl;
@@ -102,18 +255,20 @@
 
 	root.Save();
-	cout << "the new car was saved correctly!" << endl;				
+	cout << "all the transport means were saved correctly" << endl;				
 	getchar();
 
 	//////////////////////////////////// LOADING ////////////////////////////////
 
-
-	Car *loadedCar;
+	string whichone = "pepikovo";
+//	whichone = "jardovo";
+	whichone = "ondrejovo";
+
 	root.Load();
-	UserInfo::Assembly(loadedCar,root,"kara");
+	Transport *loaded = UserInfo::Assembly<Transport>( root,whichone);
 	
-	if( loadedCar )
-		cout << "loaded car: age=" << loadedCar->age << ", brand=" << loadedCar->brand << endl;
+	if( loaded )
+		loaded->ToString();
 	else
-		cout << "there was some error during car loading!" << endl;
+		cout << "there was some error during loading!" << endl;
 		
 	getchar(); 
