Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Core » How to program real U++ applications
How to program real U++ applications [message #25966] Mon, 22 March 2010 15:55 Go to next message
koldo is currently offline  koldo
Messages: 3356
Registered: August 2008
Senior Veteran
Hello all

I would like to ask you how you design professional U++ applications.

Thinking in a GUI application with a main window, how do you connect classes with main class containing main Serialize/Xmlize configuration:

- Main class is a global variable.
- You include in classes constructor as argument a pointer to main class
- You access from a subclass the main class using dynamic_cast<MainClass *>(GetParent()->GetParent()-> ... as many times as necessary.



Best regards
Iñaki
Re: How to program real U++ applications [message #25968 is a reply to message #25966] Mon, 22 March 2010 16:27 Go to previous messageGo to next message
mdelfede is currently offline  mdelfede
Messages: 1307
Registered: September 2007
Ultimate Contributor
I usually separate configuration from main class, so a "Settings" class wich contains all global settings. Example :

In "settings.h"

class Settings
{
    private:
......(all app wide settings here)

    public:
......(all getters/setters for public accessible settings)

};

Settings &globalSettings();


and, in "settings.cpp"

Settings &globalSettings()
{
    static Settings settings;

    return settings;
}


So the only public stuff is the global 'globalSettings()' function wich gives access to app-wide settings.
In settings constructor you can then put code to load (Xmlize) status, and in destructor code to save (Xmlize) status.

Ciao

Max
Re: How to program real U++ applications [message #25969 is a reply to message #25968] Mon, 22 March 2010 16:33 Go to previous messageGo to next message
mdelfede is currently offline  mdelfede
Messages: 1307
Registered: September 2007
Ultimate Contributor
Another stuff is when you want to save app data, not just settings.
That depends too much upon your app structure....
In my app I've got files containing a 'fixed' part (customer name, site and so on...) and a 'variable' part wich is composed by an array of classes derived from a main (Page, in my app) base class, so a polymorphic class array.
For 'fixed' part I just xmlize single values, and for 'variable' part..... also Xmlize, but the full array using PolyXML bazaar stuff. That makes really easy to add new data to the application with no need to touch at a single line in main app class.

Ciao

Max
Re: How to program real U++ applications [message #26025 is a reply to message #25966] Fri, 26 March 2010 14:32 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
koldo wrote on Mon, 22 March 2010 10:55

Hello all

I would like to ask you how you design professional U++ applications.

Thinking in a GUI application with a main window, how do you connect classes with main class containing main Serialize/Xmlize configuration:

- Main class is a global variable.



Never did that.

Quote:


- You include in classes constructor as argument a pointer to main class



Sometimes it is needed. Usually not.

Quote:


- You access from a subclass the main class using dynamic_cast<MainClass *>(GetParent()->GetParent()-> ... as many times as necessary.



Never did that.

Note there is nice global serialization system that perhaps is able to solve your issue.

Mirek
Re: How to program real U++ applications [message #26026 is a reply to message #25966] Fri, 26 March 2010 15:30 Go to previous messageGo to next message
zsolt is currently offline  zsolt
Messages: 696
Registered: December 2005
Location: Budapest, Hungary
Contributor
koldo wrote on Mon, 22 March 2010 15:55

Hello all

I would like to ask you how you design professional U++ applications.

Thinking in a GUI application with a main window, how do you connect classes with main class containing main Serialize/Xmlize configuration:

- Main class is a global variable.
- You include in classes constructor as argument a pointer to main class
- You access from a subclass the main class using dynamic_cast<MainClass *>(GetParent()->GetParent()-> ... as many times as necessary.



I usually use the global config scheme as well:

In your dialog cpp:
#define CONFIG_KEY "YourDialogClassName"

INITBLOCK {
	RegisterGlobalConfig(CONFIG_KEY);
}


before showing your dialog:
	LoadFromGlobal(*this, CONFIG_KEY);

After closing it:
	StoreToGlobal(*this, CONFIG_KEY);


And in your main window's Serialize method will be like this:
void MainWindow::Serialize(Stream& s)
{
	int version = 1;
	s / version;

	SerializePlacement(s);
	some_member.Serialize(s);
	SerializeGlobalConfigs(s);
	
	if(version<2) return;
	//this is used in newer versions
}
Re: How to program real U++ applications [message #26044 is a reply to message #26026] Fri, 26 March 2010 20:01 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3356
Registered: August 2008
Senior Veteran
Thank you Massimo, Mirek and Zsolt

Do you know it this global serialization is available for Xmlize?


Best regards
Iñaki
Re: How to program real U++ applications [message #26046 is a reply to message #26044] Fri, 26 March 2010 21:35 Go to previous messageGo to next message
mdelfede is currently offline  mdelfede
Messages: 1307
Registered: September 2007
Ultimate Contributor
koldo wrote on Fri, 26 March 2010 20:01

Thank you Massimo, Mirek and Zsolt

Do you know it this global serialization is available for Xmlize?


I don't think so... That's one of the reasons I use global Settings object.
BTW, I still use binary way/global serialization, but just for dialog placements/settings, I think app settings are better if centralized on a single object.

Ciao

Max
Re: How to program real U++ applications [message #26053 is a reply to message #26046] Fri, 26 March 2010 23:07 Go to previous message
koldo is currently offline  koldo
Messages: 3356
Registered: August 2008
Senior Veteran
mdelfede wrote on Fri, 26 March 2010 21:35

koldo wrote on Fri, 26 March 2010 20:01

Thank you Massimo, Mirek and Zsolt

Do you know it this global serialization is available for Xmlize?


I don't think so... That's one of the reasons I use global Settings object.
BTW, I still use binary way/global serialization, but just for dialog placements/settings, I think app settings are better if centralized on a single object.

Ciao

Max


Thank you Massimo

I think I will use your focus as I like Xmlize.

Thank you all again Smile


Best regards
Iñaki
Previous Topic: Xmlize hates spaces
Next Topic: Strange issue with VectorMap<String, String>
Goto Forum:
  


Current Time: Thu Apr 18 15:19:44 CEST 2024

Total time taken to generate the page: 0.02536 seconds