|
|
Home » Developing U++ » U++ Developers corner » Proposed change to U++ to allow owning children.
Proposed change to U++ to allow owning children. [message #31586] |
Wed, 16 March 2011 17:18 |
Lance
Messages: 527 Registered: March 2007
|
Contributor |
|
|
Newbie proposes changes to the library? Well, this is another proof of how well U++ is designed and implemented.
But will this break the "Everything belongs somewhere" principle? I don't think so. Owned Ctrls will be taken care of by their parents who own them. So they belong to their parents. As it's clearly defined and easily determineable, the principle is actually perfectly confirmed.
1. Advantage of allowing parent Ctrl to own certain child.
a. sometimes it's more natural to allocate Ctrl's on the heap;
b. it can relieve the programmer(library user) from keeping track of uninterested objects only to properly destroy them afterwards;
c. if used with discretion, it can reduce the memory footprint of generated program. I will give some examples if you don't believe me.
2. Will the proposed change break any existing code?
No. If not impossible, it's very very unprobable that the changes will affect any existing codes that was not aware of it
3. How signicant are the changes in the current libary codes to allow for children ownship?
It's minimal. I cannot handle it if it's too big as my knowledge with U++ is still very limited. About 6-10 function has been changed, another flag (1 bit) is added which will not increase memory requirement of Ctrl objects.
Here is a list of the changes (may not be complete)
A. In Ctrl.h
A.1
#ifdef PLATFORM_X11
bool ignoretakefocus:1;
#endif
bool owned:1; // <--This line
static Ptr<Ctrl> eventCtrl;
AND
// proposed changed, open door for libary developer
// but still concealed from library user
//
bool IsOwned()const{ return owned; }
void SetOwned(bool v=true){ owned=v; }
AND
// flag: 0 - not to be owned, eg for Ctrl alloc on stack or otherwise maintained
// 1 - yes, own the child, will be responsible for its destruction
// 2 or other values - the owned flag has been properly set, just use it.
void AddChild(Ctrl *child,int flag=2);
void AddChild(Ctrl *child, Ctrl *insafter,int flag=2);
void AddChildBefore(Ctrl *child, Ctrl *insbefore, int flag=2);
// seel RemoveChild0 for explanation of detachOnly parameter
//
void RemoveChild(Ctrl *child, bool detachOnly=false);
AND
// flag 2 means to leave the owned flag untouched( already properly set)
void Add(Ctrl& ctrl, int flag=2) { AddChild(&ctrl, flag); }
To be continued. I am running out of my time.
[Updated on: Wed, 16 March 2011 17:53] Report message to a moderator
|
|
|
|
|
Proposed change to U++ to allow owning children.
By: Lance on Wed, 16 March 2011 17:18
|
|
|
Re: Proposed change to U++ to allow owning children.
By: kohait00 on Wed, 16 March 2011 17:26
|
|
|
Re: Proposed change to U++ to allow owning children.
By: Lance on Wed, 16 March 2011 17:29
|
|
|
Re: Proposed change to U++ to allow owning children.
By: Lance on Wed, 16 March 2011 17:30
|
|
|
Re: Proposed change to U++ to allow owning children.
By: Lance on Wed, 16 March 2011 17:39
|
|
|
Re: Proposed change to U++ to allow owning children.
By: kohait00 on Wed, 16 March 2011 18:01
|
|
|
Re: Proposed change to U++ to allow owning children.
By: Lance on Wed, 16 March 2011 18:10
|
|
|
Re: Proposed change to U++ to allow owning children.
By: Lance on Wed, 16 March 2011 18:29
|
|
|
Re: Proposed change to U++ to allow owning children.
By: Lance on Wed, 16 March 2011 18:35
|
|
|
Re: Proposed change to U++ to allow owning children.
By: Lance on Wed, 16 March 2011 18:43
|
|
|
Re: Proposed change to U++ to allow owning children.
By: Lance on Wed, 16 March 2011 19:24
|
|
|
Re: Proposed change to U++ to allow owning children.
By: Lance on Fri, 18 March 2011 02:13
|
|
|
Re: Proposed change to U++ to allow owning children.
By: kohait00 on Fri, 18 March 2011 11:01
|
|
|
Re: Proposed change to U++ to allow owning children.
By: Lance on Fri, 18 March 2011 14:39
|
|
|
Re: Proposed change to U++ to allow owning children.
By: Lance on Fri, 18 March 2011 15:21
|
|
|
Re: Proposed change to U++ to allow owning children.
By: Lance on Fri, 18 March 2011 15:40
|
|
|
Re: Proposed change to U++ to allow owning children.
By: Lance on Fri, 18 March 2011 16:22
|
|
|
Re: Proposed change to U++ to allow owning children.
By: Lance on Fri, 18 March 2011 16:34
|
|
|
Re: Proposed change to U++ to allow owning children.
By: mirek on Fri, 18 March 2011 19:35
|
|
|
Re: Proposed change to U++ to allow owning children.
By: mirek on Fri, 18 March 2011 19:32
|
|
|
Re: Proposed change to U++ to allow owning children.
By: Lance on Fri, 18 March 2011 23:02
|
|
|
Re: Proposed change to U++ to allow owning children.
By: mirek on Fri, 18 March 2011 23:18
|
|
|
Re: Proposed change to U++ to allow owning children.
By: Lance on Fri, 18 March 2011 23:34
|
|
|
Re: Proposed change to U++ to allow owning children.
By: mirek on Fri, 18 March 2011 23:40
|
|
|
Re: Proposed change to U++ to allow owning children.
By: Lance on Sat, 19 March 2011 00:02
|
|
|
Re: Proposed change to U++ to allow owning children.
By: mirek on Sat, 19 March 2011 00:37
|
|
|
Re: Proposed change to U++ to allow owning children.
By: Lance on Sat, 19 March 2011 01:30
|
|
|
Re: Proposed change to U++ to allow owning children.
By: Lance on Sat, 19 March 2011 01:35
|
|
|
Re: Proposed change to U++ to allow owning children.
By: mirek on Sat, 19 March 2011 10:59
|
|
|
Re: Proposed change to U++ to allow owning children.
By: kohait00 on Sun, 20 March 2011 10:32
|
|
|
Re: Proposed change to U++ to allow owning children.
By: Lance on Sun, 20 March 2011 14:07
|
|
|
Re: Proposed change to U++ to allow owning children.
By: Lance on Sun, 20 March 2011 14:11
|
|
|
Re: Proposed change to U++ to allow owning children.
By: Lance on Sun, 20 March 2011 14:28
|
|
|
Re: Proposed change to U++ to allow owning children.
By: kohait00 on Fri, 25 March 2011 13:26
|
|
|
Re: Proposed change to U++ to allow owning children.
By: Lance on Sun, 27 March 2011 15:33
|
|
|
Re: Proposed change to U++ to allow owning children.
By: kohait00 on Sun, 17 April 2011 17:25
|
|
|
Re: Proposed change to U++ to allow owning children.
By: Lance on Tue, 19 April 2011 06:00
|
|
|
Re: Proposed change to U++ to allow owning children.
By: kohait00 on Tue, 19 April 2011 09:14
|
|
|
Re: Proposed change to U++ to allow owning children.
By: Lance on Tue, 19 April 2011 14:09
|
|
|
Re: Proposed change to U++ to allow owning children.
By: kohait00 on Tue, 19 April 2011 18:05
|
|
|
Re: Proposed change to U++ to allow owning children.
By: Lance on Wed, 20 April 2011 02:44
|
|
|
Re: Proposed change to U++ to allow owning children.
By: kohait00 on Wed, 20 April 2011 08:51
|
|
|
Re: Proposed change to U++ to allow owning children.
By: Lance on Wed, 20 April 2011 19:24
|
|
|
Re: Proposed change to U++ to allow owning children.
By: Lance on Wed, 20 April 2011 21:17
|
|
|
Re: Proposed change to U++ to allow owning children.
By: Lance on Wed, 20 April 2011 21:23
|
|
|
Re: Proposed change to U++ to allow owning children.
By: Lance on Wed, 20 April 2011 21:38
|
|
|
Re: Proposed change to U++ to allow owning children.
By: kohait00 on Thu, 28 April 2011 16:32
|
|
|
revised ownership change
By: kohait00 on Thu, 28 April 2011 18:28
|
|
|
Re: revised ownership change
By: Lance on Thu, 28 April 2011 21:45
|
|
|
Re: revised ownership change
By: kohait00 on Thu, 28 April 2011 21:57
|
|
|
Re: revised ownership change
By: Lance on Thu, 28 April 2011 23:18
|
|
|
Re: revised ownership change
By: Lance on Thu, 28 April 2011 23:31
|
|
|
Re: revised ownership change
By: Lance on Thu, 28 April 2011 23:54
|
|
|
Re: revised ownership change
|
|
|
Re: revised ownership change
|
|
|
Re: revised ownership change
|
|
|
Re: revised ownership change
By: Lance on Mon, 06 June 2011 05:11
|
|
|
Re: revised ownership change
By: Lance on Mon, 06 June 2011 05:05
|
Goto Forum:
Current Time: Sun Apr 28 21:46:04 CEST 2024
Total time taken to generate the page: 0.06252 seconds
|
|
|