473,503 Members | 1,188 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Adding an instance to a data tree

Hi,
I have a data tree. A node in the tree "assembles" itself when called
upon to do so by the level-of-detail algorithm.
It creates and adds its children to itself using a base class method
called "add". However in the pseudo-constructor called "setup", the
child node needs to be already linked into the tree in order to obtain
configuration information. So the "add" method creates the child,
optionally positions it within the parents frame of reference, then
invokes the child's setup method which has variable length arguments.
Here is an example of code in an assemble method.

self.add("Reservoir", (Reservoir, r, r +
self.inner_tank_thickness))
self.add("End_tank", (End_tank, r,
self.outer_tank_radius),
0.5*self.payload_length +
0.5*self.outer_tank_thickness)
self.add("Inner_end_tank", (End_tank, r,
self.outer_tank_radius),
-0.5*self.payload_length
-0.5*self.outer_tank_thickness)
self.add("Zero_G_port", Zero_G_port,
0.5*self.payload_length
-0.5*self.zg_length)
self.add("Hangar-floor", Hangar)
self.add("herc", Hercules_shuttle,
(0.5*self.payload_length - 25,
R3d(180.0,V3d(0,1,0))))
self.add("herc1", Hercules_shuttle,

(V3d(0,-12.5,0.5*self.payload_length - 25), R3d(180.0,V3d(0,1,0))))

The add method takes the parameters "name", child-information, and
optional location-information.
The child information is either a class, or a tuple whose first member
is a class. The remaining members of the tuple are parameters to the
class setup method.

The problem is this: Sometimes the setup method parameters are quite
numerous, leading to problems when the order is misjudged. If invoked
directly, then naming parameters minimises the problems with missed
parameters. However the indirect creation via the "add" method means
the parameters are passed in a tuple, so the parameters cannot be
named.

How can I "pre-construct" the children with parent id and optional
location information, and also implement the advantages of named
function parameters?
Looking for all suggestions.

Dec 19 '06 #1
1 1014

And of course the solution occurs to me about 30 minutes after posting,
to have the add method return an instance which then invokes setup.
self.add(name, child_type, other_info).setup(child-setup-parameters)

Dec 19 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
9742
by: muralidharan | last post by:
WebForm1.aspx Code: <%@ Register TagPrefix="ComponentArt" Namespace="ComponentArt.Web.UI" Assembly="ComponentArt.Web.UI" %> <ComponentArt:TreeView id="TreeView1" Height="520"...
2
1615
by: New | last post by:
Why does this code insert a node into a binary search tree correctly? If I only inserting going by first digit it works properly but when I try inserting going by the whole ip and the port number...
9
5472
by: James Geurts | last post by:
Hey all... I posted this in the vs.net ide group too, but people are not answering, so I figured that it might be more appropriate here. I'm not sure if I'm adding a designer to my code properly. ...
3
2451
by: Brian Henry | last post by:
If i already have a tree view created, and want to add another new node to it, how would i do so? Is there a way to throught tags or anything? like i have this RootNode | +-- Child 1 +--...
4
2285
by: pmcguire | last post by:
I have a treeview with a lot of nodes. I want to load only the nodes that are initially visible when the form loads, and then continue to populate it in background and/or when the nodes are required...
4
1235
by: Paul McKenna | last post by:
Hello I have a treeview control on my form. The nodes of this tree are populated with values from an XML file. Is there a way by which I could bind objects to the tree instead of simple strings?...
12
1583
by: Bob Jones | last post by:
I have an odd business requirement and I think that the implementation is not correct in the terms of OOP development. Any help on the concepts would be very appreciated! We currently have a...
2
15043
by: ChrisCicc | last post by:
Hi All, I got a real doozy here. I have read hundreds upon hundreds of forum posts and found numerous others who have replicated this problem, but have yet to find a solution. Through testing I have...
21
2331
by: John Henry | last post by:
Hi list, I have a need to create class methods on the fly. For example, if I do: class Dummy: def __init__(self): exec '''def method_dynamic(self):\n\treturn self.method_static("it's...
0
7203
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7089
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7339
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6995
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7463
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
4678
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3157
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
738
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
389
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.